Skip to content

Instantly share code, notes, and snippets.

@setoh2000
Created November 6, 2012 19:48
Show Gist options
  • Save setoh2000/4027038 to your computer and use it in GitHub Desktop.
Save setoh2000/4027038 to your computer and use it in GitHub Desktop.
Viewの周りに余白(margin)を付けて枠線を付ける
CGFloat margin = 3.0;
CGFloat w = aView.bounds.size.width;
CGFloat h = aView.bounds.size.height;
CALayer *borderLayer = [CALayer layer];
borderLayer.borderColor = [UIColor lightGrayColor].CGColor;
borderLayer.borderWidth = 1;
borderLayer.frame = CGRectMake(-margin, -margin, w + margin * 2, h + margin * 2);
[aView.layer addSublayer:borderLayer];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment