view添加边框(添加layer属性值)
例:
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
view.layer.masksToBounds=YES;
view.layer.cornerRadius=0.2;
view.layer.borderWidth=0.5;
view.layer.borderColor=[[UIColor lightGrayColor] CGColor];
- (void)addSublayer:(CALayer *)layer;
例:
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
CALayer *bottomBorder = [CALayer layer];
float height1=view.frame.size.height-0.5f;
float width1=view.frame.size.width;
bottomBorder.frame = CGRectMake(0.0f, height1, width1, 0.5f);
bottomBorder.backgroundColor = [UIColor blackColor].CGColor;
[view.layer addSublayer:bottomBorder];