CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Jan 2015 |
| SPMSupports SPM | ✗ |
Maintained by Cem Olcay.
UIKit toolset for quick prototyping and rapid development
convenience init (x: CGFloat,
y: CGFloat,
w: CGFloat,
h: CGFloat) var x: CGFloat {
get {
return self.frame.origin.x
} set (value) {
self.frame = CGRect (x: value, y: self.y, width: self.w, height: self.h)
}
} var y: CGFloat {
get {
return self.frame.origin.y
} set (value) {
self.frame = CGRect (x: self.x, y: value, width: self.w, height: self.h)
}
} var w: CGFloat {
get {
return self.frame.size.width
} set (value) {
self.frame = CGRect (x: self.x, y: self.y, width: value, height: self.h)
}
} var h: CGFloat {
get {
return self.frame.size.height
} set (value) {
self.frame = CGRect (x: self.x, y: self.y, width: self.w, height: value)
}
} var position: CGPoint {
get {
return self.frame.origin
} set (value) {
self.frame = CGRect (origin: value, size: self.frame.size)
}
} var size: CGSize {
get {
return self.frame.size
} set (value) {
self.frame = CGRect (origin: self.frame.origin, size: size)
}
} var left: CGFloat {
get {
return self.x
} set (value) {
self.x = value
}
} var right: CGFloat {
get {
return self.x + self.w
} set (value) {
self.x = value - self.w
}
} var top: CGFloat {
get {
return self.y
} set (value) {
self.y = value
}
} var bottom: CGFloat {
get {
return self.y + self.h
} set (value) {
self.y = value - self.h
}
} func leftWithOffset (offset: CGFloat) -> CGFloat
func rightWithOffset (offset: CGFloat) -> CGFloat
func topWithOffset (offset: CGFloat) -> CGFloat
func botttomWithOffset (offset: CGFloat) -> CGFloat enum AnchorPosition: CGPoint {
case TopLeft = "{0, 0}"
case TopCenter = "{0.5, 0}"
case TopRight = "{1, 0}"
case MidLeft = "{0, 0.5}"
case MidCenter = "{0.5, 0.5}"
case MidRight = "{1, 0.5}"
case BottomLeft = "{0, 1}"
case BottomCenter = "{0.5, 1}"
case BottomRight = "{1, 1}"
} func setAnchorPosition (anchorPosition: AnchorPosition)Adding shadow
func addShadow (offset: CGSize,
radius: CGFloat,
color: UIColor,
opacity: Float)Adding borders
func addBorder (width: CGFloat,
color: UIColor)Setting corner radius of borders
func setCornerRadius (radius: CGFloat)Adding stroke to borders
func drawStroke (width: CGFloat,
color: UIColor)Circle Drawing
func drawCircle (fillColor: UIColor,
strokeColor: UIColor,
strokeWidth: CGFloat)Arc Drawing
func drawArc (from: CGFloat,
to: CGFloat,
clockwise: Bool,
width: CGFloat,
fillColor: UIColor,
strokeColor: UIColor,
lineCap: String)Rotation
func setRotationX (x: CGFloat)
func setRotationY (y: CGFloat)
func setRotationZ (z: CGFloat)
func setRotation (x: CGFloat,
y: CGFloat,
z: CGFloat)Scale
func setScale (x: CGFloat,
y: CGFloat)Constants
let UIViewAnimationDuration: NSTimeInterval = 1
let UIViewAnimationSpringDamping: CGFloat = 0.5
let UIViewAnimationSpringVelocity: CGFloat = 0.5Animation Mehtods
func animate (animations: (()->Void)!,
completion: ((Bool)->Void)? = nil)
func spring (animations: (()->Void)!,
completion: ((Bool)->Void)? = nil)Tap
func addTapGesture (tapNumber: NSInteger,
target: AnyObject, action: Selector)Swipe
func addSwipeGesture (
direction: UISwipeGestureRecognizerDirection,
numberOfTouches: Int,
target: AnyObject,
action: Selector) Pan
func addPanGesture (target: AnyObject,
action: Selector)Top
var top: CGFloat {
get {
if let nav = self.navigationController {
if nav.navigationBarHidden {
return view.top
} else {
return nav.navigationBar.bottom
}
} else {
return view.top
}
}
}Bottom
var bottom: CGFloat {
get {
if let tab = tabBarController {
if tab.tabBar.hidden {
return view.bottom
} else {
return tab.tabBar.top
}
} else {
return view.bottom
}
}
} var applicationFrame: CGRect {
get {
return CGRect (x: view.x, y: top, width: view.w, height: bottom - top)
}
} var navigationBar: UINavigationBar? {
get {
return navigationController?.navigationBar
}
}Get Navigation bar height of device
var navigationBarHeight: CGFloat {
get {
if let nav = self.navigationController {
return nav.navigationBar.h
}
return 0
}
}Get or set navigation bar color
var navigationBarColor: UIColor? {
get {
return navigationController?.navigationBar.tintColor
} set (value) {
navigationController?.navigationBar.barTintColor = value
}
}AttributedStrings property for accessing, adding or updating attributedText of label private var UILabelAttributedStringArray: UInt8 = 0
var attributedStrings: [NSAttributedString]? {
get {
return objc_getAssociatedObject(self, &UILabelAttributedStringArray) as? [NSAttributedString]
} set (value) {
objc_setAssociatedObject(self, &UILabelAttributedStringArray, value, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
}
}
Adding
func addAttributedString (text: String,
color: UIColor,
font: UIFont)
func addAttributedString (attributedString: NSAttributedString)Updating
func updateAttributedStringAtIndex (index: Int,
attributedString: NSAttributedString)
func updateAttributedStringAtIndex (index: Int,
newText: String) func getEstimatedHeight () -> CGFloat
func fitHeight () subscript (i: Int) -> String {
return String(Array(self)[i])
}enums for easily create UIFonts enum FontType: String
enum FontName: String
class func Font (name: FontName, type: FontType, size: CGFloat) -> UIFontEven customise it for specific font
class func HelveticaNeue (type: FontType, size: CGFloat) -> UIFontPrint all family of font on single line
class func PrintFontFamily (font: FontName) class func randomColor () -> UIColor class func RGBColor (r: CGFloat,
g: CGFloat,
b: CGFloat) -> UIColor class func RGBAColor (r: CGFloat,
g: CGFloat,
b: CGFloat,
a: CGFloat) -> UIColorCalculate possible aspect width for height
func aspectWidthForHeight (height: CGFloat) -> CGFloatCalculate possible aspect height for width
func aspectHeightForWidth (width: CGFloat) -> CGFloatResize image based on its width (auto calculates height and keeps aspect ratio)
func aspectResizeWithWidth (width: CGFloat) -> UIImageResize image based on its height (auto calculates width and keeps aspect ratio)
func aspectResizeWithHeight (height: CGFloat) -> UIImageCGPoints func + (left: CGPoint, right: CGPoint) -> CGPoint
func - (left: CGPoint, right: CGPoint) -> CGPointStringLiteralConvertable implementation public init(stringLiteral value: StringLiteralType)
public init(extendedGraphemeClusterLiteral value: StringLiteralType)
public init(unicodeScalarLiteral value: StringLiteralType) {
self = CGPointFromString(value)CGSizes func + (left: CGSize, right: CGSize) -> CGSize
func - (left: CGSize, right: CGSize) -> CGSizeScreen Width
var ScreenWidth: CGFloat {
get {
return UIScreen.mainScreen().bounds.size.width
}
}Screen Height
var ScreenHeight: CGFloat {
get {
return UIScreen.mainScreen().bounds.size.height
}
}Status bar height
var StatusBarHeight: CGFloat {
get {
return UIApplication.sharedApplication().statusBarFrame.height
}
} func degreesToRadians (angle: CGFloat) -> CGFloatConvert [min, max] to [0, 1]
func normalizeValue (value: CGFloat,
min: CGFloat,
max: CGFloat) -> CGFloatConvert [0, 1] to to [min, max]
func convertNormalizedValue (value: CGFloat,
min: CGFloat,
max: CGFloat) -> CGFloat func alert (title: String,
message: String,
cancelAction: ((UIAlertAction!)->Void)? = nil,
okAction: ((UIAlertAction!)->Void)? = nil) -> UIAlertController func barButtonItem (imageName: String,
action: (AnyObject)->()) -> UIBarButtonItem func barButtonItem (title: String,
color: UIColor,
action: (AnyObject)->()) -> UIBarButtonItemUIButton with actionBlock:
var actionBlock: ((sender: BlockButton) -> ())? {
didSet {
self.addTarget(self, action: "action:", forControlEvents: UIControlEvents.TouchUpInside)
}
}
func action (sender: BlockButton) {
actionBlock! (sender: sender)
}UIWebView with block based actions instead of UIWebViewDelegate
var didStartLoad: ((NSURLRequest) -> ())?
var didFinishLoad: ((NSURLRequest) -> ())?
var didFailLoad: ((NSURLRequest, NSError) -> ())?
var shouldStartLoadingRequest: ((NSURLRequest) -> (Bool))?