Created
April 28, 2015 15:13
-
-
Save zachmayberry/50e29bdf65f8bb7dd37b to your computer and use it in GitHub Desktop.
Add borders to UIView
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
- (void)addBorders { | |
// Set thickness | |
NSInteger borderThickness = 1; | |
// Comment out each border not needed | |
UIView *topBorder = [UIView new]; | |
topBorder.backgroundColor = [UIColor lightGrayColor]; | |
topBorder.frame = CGRectMake(0, 0, myView.frame.size.width, borderThickness); | |
[myView addSubview:topBorder]; | |
UIView *bottomBorder = [UIView new]; | |
bottomBorder.backgroundColor = [UIColor lightGrayColor]; | |
bottomBorder.frame = CGRectMake(0, myView.frame.size.height - borderThickness, myView.frame.size.width, borderThickness); | |
[myView addSubview:bottomBorder]; | |
UIView *leftBorder = [UIView new]; | |
leftBorder.backgroundColor = [UIColor lightGrayColor]; | |
leftBorder.frame = CGRectMake(0, 0, borderThickness, myView.frame.size.height); | |
[myView addSubview:leftBorder]; | |
UIView *rightBorder = [UIView new]; | |
rightBorder.backgroundColor = [UIColor lightGrayColor]; | |
rightBorder.frame = CGRectMake(myView.frame.size.width - borderThickness, 0, borderThickness, myView.frame.size.height); | |
[myView addSubview:rightBorder]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment