添加边框
UIView *shadowView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
shadowView.backgroundColor = [UIColor brownColor];
//边框
shadowView.layer.borderColor = [[UIColor blackColor] CGColor];
shadowView.layer.borderWidth = 5.0f;
添加阴影
UIView *shadowView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
shadowView.backgroundColor = [UIColor brownColor];
//阴影,四个边都添加阴影
shadowView.layer.shadowColor = [UIColor blackColor].CGColor;
shadowView.layer.shadowOffset = CGSizeMake(0, 0);
shadowView.layer.shadowOpacity = 0.5;
shadowView.layer.shadowRadius = 10.0;
shadowView.clipsToBounds = NO;
shadowOffset这个属性可以控制阴影的偏移,为(0,0)时不偏移,分别代表在x和y轴上的偏移距离。
网友评论