A collection of designable components I often use in my iOS projects. Checkout the Example project to see all available options.
To run the example project, clone the repo, and run carthage bootstrap --no-use-binaries --platform ios
from the Example directory first.
Dezignables is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Dezignables"
Dezignables are implemented using protocol extensions. The pre-made components include all or most of the dezignables available and are ready to use. You could also apply one or more of the dezignable protocols on your own components.
Class | Dezignables |
---|---|
DezignableView |
|
DezignableButton |
|
DezignableImageView |
|
DezignableLabel |
|
DezignableTableViewController |
|
DezignableViewController |
|
Property | Description | Preview |
---|---|---|
borderWidth | Sets the width of the border in points | ✅ |
borderColor | Color of the border | ✅ |
borderTop | Draws top border | ✅ |
borderBottom | Draws bottom border | ✅ |
borderLeft | Draws left border | ✅ |
borderRight | Draws right border | ✅ |
borderScaleCorrection | Converts the borderWidth to physical pixels. The borderWidth value gets divided by UIScreen.mainScreen().scale . To create a hairline border use borderWidth=1.0 and borderScaleCorrection=true . |
✅ |
Property | Description | Preview |
---|---|---|
cornerRadius | The radius of all four corners, in points | ✅ |
cornerCircle | Make a full circle based on the height of the view. The preview looks weird when used with DezignableRotation |
✅ |
Property | Description | Preview |
---|---|---|
rotation | The amount of degrees the view should rotate | ❌ |
Property | Description | Preview |
---|---|---|
backgroundFillColor | Fill the view with a solid color | ✅ |
backgroundGradientStartColor | Start color of the gradient | ✅ |
backgroundGradientStopColor | Stop color of the gradient | ✅ |
backgroundGradientStartPoint | Position of the start color in the gradient | ✅ |
backgroundGradientStopPoint | Position of the stop color in the gradient | ✅ |
When you want to use DezignableShadow
together with DezignableBorder
you'll need to use two different views and lay them out exactly on top of each other. See the Example app for a demo.
Property | Description | Preview |
---|---|---|
boxShadowColor | The color of the shadow | ❌ |
boxShadowRadius | How far out the shadow will spread | ❌ |
boxShadowOpacity | How transparant the shadow will be. 0.0 is invisible, 1.0 is fully visible | ❌ |
boxShadowOffset | From what point the shadow will draw | ❌ |
This is a table cell separator that doesn't dissapear when selecting the cell. Cells need to be a subclass of DezignableTableViewCell
, or you can use DezignableTableViewCell
directly.
Property | Description | Preview |
---|---|---|
separatorColor | The color of the separator | ❌ |
separatorWidth | The width of the separator, in points | ❌ |
separatorScaleCorrection | Converts the separatorWidth to physical pixels. The separatorWidth value gets divided by UIScreen.mainScreen().scale . To create a hairline border use separatorWidth=1.0 and borderScaleCorrection=true . |
❌ |
DezignableHiddenSections
These functions can be called from a subclass of DezignableTableViewController
or directly on the controller.
Function | Description | Preview |
---|---|---|
hideSection(section: Int) | Hides the given section (section index is zero-based) | ❌ |
showSection(section: Int) | Shows the given section (section index is zero-based) | ❌ |
isSectionHidden(section: Int) -> Bool | Returns true when given section is hidden (section index is zero-based) |
❌ |
A custom highlight and selection background color for table cells and buttons. Cells need to be a subclass of DezignableTableViewCell
or you can use DezignableTableViewCell
directly.
Property | Description | Preview |
---|---|---|
selectedBackgroundColor | The color used when the cell is selected | Cell: ❌ - Button: ✅ |
highlightBackgroundColor | The color used when the cell is highlighted, for cells the selectedBackgroundColor is used when this value is nil |
Cell: ❌ - Button: ✅ |
normalBackgroundColor | The default background color of the cell, defaults to UIColor.whiteColor() |
Cell: ❌ - Button: ✅ |
DezignableHiddenNavigationBar
Property | Description | Preview |
---|---|---|
navigationBarHidden | Whether or not the navigation bar is hidden for this view controller | ❌ |
Property | Description | Preview |
---|---|---|
statusBarLight | Shows a light status bar for this view controller | ❌ |
statusBarHidden | Whether or not the status bar is hidden for this view controller | ❌ |
Dezignables is available under the MIT license. See the LICENSE file for more info.