Skip to content

Instantly share code, notes, and snippets.

@dtrauger
Last active March 25, 2022 19:29
Show Gist options
  • Save dtrauger/5722805 to your computer and use it in GitHub Desktop.
Save dtrauger/5722805 to your computer and use it in GitHub Desktop.
Programatically Adding Border to View in Objective C
CALayer *topBorder = [CALayer layer];
topBorder.frame = CGRectMake(0.0f, 0.0, viewForBorder.frame.size.width, 1.0f);
topBorder.borderWidth = 1;
topBorder.borderColor = [UIColor colorWithRed:58.0/255.0 green:58.0/255.0 blue:58.0/255.0 alpha:1.0].CGColor;
[theView.layer addSublayer:topBorder];
@Monte9
Copy link

Monte9 commented Nov 17, 2018

This is one of the best, most concise solutions I have found! Thanks a lot! 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment