Created
February 2, 2016 12:12
-
-
Save dipkasyap/0c73096bd90940d9c758 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| extension UIView{ | |
| func addBorderOf(color color:UIColor?, withWidth width:CGFloat?,ofCornorRadious radious:CGFloat?) { | |
| self.layer.borderColor = color?.CGColor | |
| if let width = width{ | |
| self.layer.borderWidth = width | |
| } else { | |
| self.layer.borderWidth = 0 | |
| } | |
| if let color = color{ | |
| self.layer.borderColor = color.CGColor | |
| } else { | |
| self.layer.borderColor = UIColor.whiteColor().CGColor | |
| } | |
| if let radious = radious{ | |
| self.layer.cornerRadius = radious | |
| } else { | |
| self.layer.cornerRadius = 0 | |
| } | |
| self.clipsToBounds = true | |
| } | |
| func addDoubleCircularBorderWith(color color:UIColor?,innnerWidth iWidth:CGFloat?, outerWidth oWidth:CGFloat?, outerColor oColor:UIColor?){ | |
| self.layer.cornerRadius = self.frame.height/2 | |
| self.clipsToBounds = true | |
| self.layer.borderColor = color?.CGColor | |
| self.layer.borderWidth = iWidth! | |
| let outerBorder = CALayer() | |
| outerBorder.cornerRadius = self.layer.cornerRadius+self.layer.borderWidth | |
| outerBorder.borderWidth = 5 | |
| outerBorder.borderColor = oColor?.CGColor | |
| outerBorder.backgroundColor = UIColor.clearColor().CGColor | |
| self.layer.addSublayer(outerBorder) | |
| } | |
| func makeCircular(){ | |
| self.layer.cornerRadius = self.frame.height/2 | |
| self.clipsToBounds = true | |
| } | |
| func setUnderline(ofColor color:UIColor, andSize sized:CGFloat){ | |
| //Making UnderLIne BOrder on UitextFld | |
| let underLine = CALayer() | |
| underLine.frame = CGRectMake(0.0, self.frame.size.height - 1, self.frame.size.width, sized); | |
| underLine.backgroundColor = color.CGColor | |
| self.layer.addSublayer(underLine) | |
| } | |
| func setUnderlineOnCell(ofColor color:UIColor,ofSize:CGFloat?){ | |
| //Making UnderLIne BOrder on UitextFld | |
| for layer in self.layer.sublayers! { | |
| if layer.name == "underLine"{ | |
| layer.removeFromSuperlayer() | |
| } | |
| } | |
| var uSize:CGFloat = 1 | |
| if let h = ofSize { | |
| uSize = h | |
| } | |
| let underLine = CALayer() | |
| underLine.name = "underLine" | |
| underLine.frame = CGRectMake(8, self.frame.size.height - 1, self.frame.size.width-16, uSize); | |
| underLine.backgroundColor = color.CGColor//UIColor(red: 0.718, green: 0.714, blue: 0.718, alpha: 1.00).CGColor | |
| self.layer.addSublayer(underLine) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment