iOS framework that provides customisable UI components via UIStoryboard. The framework includes following UI components:
Add the following to your target in your project's pod file
pod 'KUIKit'
- KView
- KButton
- KTextField
- KProgressbar
- KCircularProgressbar
Apart from the above UI components, KUIKit offers some UI utility functions and structures.
KView
let kView = KView()
kView.borderColor = UIColor.orange
kView.borderWidth = 1
kView.cornerRadius = 3
// For gradient
kView.startColor = UIColor.yellow
kView.endColor = UIColor.orange
kView.verticalGradient = false // To render gradient horizontally.
view.addSubView(kView)
KButton
let kButton = KButton()
kButton.onClick = {
// Adding click listener is so simple for KButton.
}
kButton.cornerRadius = 3
kButton.borderWidth = 1
kButton.borderColor = UIColor.orange
// For gradient
kButton.startColor = UIColor.yellow
kButton.endColor = UIColor.orange
kButton.verticalGradient = true // gradient is rendered vertically. Default is vertical.
view.addSubView(kButton)
KTextField
let kTextField = KTextField()
// You can have borders and corner radius
kTextField.borderColor = UIColor.orange
kTextField.borderWidth = 1
kTextField.cornerRadius = 3
// Or you can have underline at the bottom
kTextField.underLineWidth = 2
kTextField.underLineColor = UIColor.gray
kTextField.underLineColorWhenFocused = UIColor.red
view.addSubview(kTextField)
KProgressbar
let kProgressbar = KProgressbar()
kProgressbar.backgroundColor = UIColor.gray
kProgressbar.progressColor = UIColor.red
// Set progress without animation. (max progress is 100)
kProgressbar.progress = 20
// Or use animation to set progress.
kProgressbar.setProgress(value: 20, animated: true, animationDuration: 0.5) { (completed) in
// Yay! you get a callback after the animation. Do some stuff here..
}
view.addSubview(kProgressbar)
KCircularProgressbar
let kCircularProgressbar = KCircularProgressbar(frame: CGRect(x: 16, y: 100, width: 100, height: 100))
kCircularProgressbar.lineWidth = 2 // Thickness if the progressbar.
kCircularProgressbar.placeHolderTint = UIColor.gray // default bachground color.
kCircularProgressbar.progressTint = UIColor.red // Color for the progress.
kCircularProgressbar.progressLabelTint = UIColor.red // Color of the progress indicator label.
kCircularProgressbar.showsLabel = true // To show progress indicator label.
kCircularProgressbar.progress = 0.3 // Set progress in float value from 0 to 1
// Or you can set progress with animation.
kCircularProgressbar.setProgress(progress: 0.4, animated: true, animationDuration: 0.5) { (completed) -> (Void) in
// Yay! you get a callback after the animation. Do some stuff here..
}
view.addSubview(kCircularProgressbar)
Orientation
KUIKit offers Orientation structure which has following features:
// Get current orientation
let currentOrientation = Orientation.orientation
// Do somethig with your currentOrientation...
// Check if the orientation is portrait or landscape.
// You don't need to get the currentOrientation and perform switch case of if-else check.
// Orientation structure does that for you.
if Orientation.isPortrait {
// Your code here...
}
if Orientation.isPortraitUpsideDown {
// Your code here...
}
if Orientation.isLandscape {
// Your code here...
}
if Orientation.isLandscapeLeft {
// Your code here...
}
if Orientation.isLandscapeRight {
// Your code here...
}
if Orientation.isFaceUp {
// Your code here...
}
if Orientation.isFaceDown {
// Your code here...
}
Device
KUIKit also offers the Device structure that tells you whether the device is iPad or iPhone.
// Get current device
let device = Device.Current
// Check if the device is iPad or iPhone
if Device.isiPad {
// It's an iPad
}
if Device.isiPhone {
// It's an iPhone
}
Screen
KUIKit also offers Screen structure which helps you get information about device's main screen.
// Get main screen
let screen = Screen.Main
// Other properties
let scale = Screen.ScreenScale
let size = Screen.ScreenSize
let height = Screen.ScreenHeight
let width = Screen.ScreenWidth
UIView Extension
No worries even if your UIComponent or your view is not from KUIKit. You can still customise it.
KUIKit has few extensions for UIView.
// If your view is not the sub class of KView,
// you can stil be able to customise it programmatically using KUIKit
let myView = UIView()
// Add corner radius with KUIKit
myView.clipWithCornerRadius(radius: 5)
// Add border of your preferred width and color using KUIKit
myView.addBorder(width: 1, color: UIColor.red)
// Apply card design to your view using KUIKit
myView.applyCardDesign()
view.addSubview(myView)
// applyCardDesign() uses the constants from the DefaultCardStyle structure.
// DefaultCardStyle has following properties.
DefaultCardStyle.CardBorderColor
DefaultCardStyle.CardBorderWidth
DefaultCardStyle.CardCornerRadius
DefaultCardStyle.CardShadowColor
DefaultCardStyle.CardShadowOffset
DefaultCardStyle.CardShadowOpacity
DefaultCardStyle.CardShadowRadius
Kalpesh Talkar
Facebook: kalpesh.talkar
Twitter: @KalpeshTalkar
Email: kalpeshtalkar@gmail.com
KUIKit is available under MIT license. See the LICENSE file for more info.