Created
May 22, 2018 05:27
-
-
Save damodarnamala/0dfc1bcaa82433c6504f4b4cb821c8cd to your computer and use it in GitHub Desktop.
IOS Theme UI Eelements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
enum LabelType : Int { | |
case small | |
case normal | |
case bold | |
case heading | |
} | |
@IBDesignable | |
class Label: UILabel { | |
var displayType : LabelType = .normal | |
@IBInspectable var labelDisplayType : Int { | |
get { | |
return self.displayType.rawValue | |
} | |
set( index) { | |
self.displayType = LabelType(rawValue: index)! | |
self.setLabelType(type: self.displayType) | |
} | |
} | |
func setLabelType(type: LabelType) { | |
switch type { | |
case .small: | |
self.font = UIFont.init(name: "Arial", size: 12) | |
self.textColor = UIColor.gray.withAlphaComponent(0.75) | |
case .normal: | |
self.font = UIFont.init(name: "Arial", size: 14) | |
self.textColor = UIColor.darkGray | |
case .bold: | |
self.font = UIFont.init(name: "Arial", size: 14) | |
self.textColor = UIColor.red.withAlphaComponent(1) | |
case .heading: | |
self.font = UIFont.init(name: "Helvetica-Bold", size: 16) | |
self.textColor = UIColor.purple.withAlphaComponent(1) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@IBDesignable | |
class TextField: UITextField { | |
enum ImageDirection { | |
case left | |
case right | |
} | |
@IBInspectable var sholdShowRightView : Int = 0 { | |
didSet { | |
if sholdShowRightView == 1 { | |
self.setImageDirection(direction: .right) | |
} | |
} | |
} | |
@IBInspectable var sholdShowLeftView : Int = 0 { | |
didSet { | |
if sholdShowLeftView == 1 { | |
self.setImageDirection(direction: .left) | |
} | |
} | |
} | |
@IBInspectable var showBorder : Int = 0 { | |
didSet { | |
if sholdShowLeftView == 1 { | |
self.layer.borderColor = UIColor.lightGray.cgColor | |
self.layer.borderWidth = 1 | |
} | |
} | |
} | |
func setImageDirection(direction: ImageDirection) { | |
switch direction { | |
case .left: | |
self.leftView = UIImageView(image: UIImage(named: "left")) | |
self.leftViewMode = .always | |
case .right: | |
self.rightView = UIImageView(image: UIImage(named: "right")) | |
self.rightViewMode = .always | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment