我需要一个带有背景图像、顶部圆角和阴影的 UIButton。这是我的代码
我从堆栈溢出中尝试了很多帖子,但没有一个对我有用。
我能够使用以下方法添加具有圆角和阴影的背景图像的 UIButton。
CALayer *imageLayer = [imageButton layer];
imageLayer.frame = CGRectMake(110, 190, 100, 100);
imageLayer.cornerRadius = 10.0;
imageLayer.shadowColor = [UIColor grayColor].CGColor;
imageLayer.shadowOpacity = 1.0;
imageLayer.shadowRadius = 1;
imageLayer.shadowOffset = CGSizeMake(03.0f, 08.0f);
imageLayer.masksToBounds = YES;
CALayer *sublayer = [CALayer layer];
sublayer.backgroundColor = [UIColor blueColor].CGColor;
sublayer.shadowOffset = CGSizeMake(5, 8);
sublayer.shadowRadius = 2.0;
sublayer.shadowColor = [UIColor grayColor].CGColor;
sublayer.shadowOpacity = 0.8;
sublayer.frame = imageLayer.frame;
sublayer.borderColor = [UIColor blackColor].CGColor;
sublayer.borderWidth = 0.0;
sublayer.cornerRadius = 10.0;
[imageButton.layer.superlayer insertSublayer:sublayer atIndex:0];
现在我怎样才能使顶角变圆。