gpt4 book ai didi

ios - 创建圆角 View

转载 作者:可可西里 更新时间:2023-11-01 03:37:52 26 4
gpt4 key购买 nike

美好的一天!

我试图让我的 View (主视图中的 View )变成圆角。我这样做,但它不起作用。有任何想法吗?

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
currenView = [[UIView alloc] init];

UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:currenView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(30.0, 30.0)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = currenView.bounds;
maskLayer.path = maskPath.CGPath;
currenView.layer.mask = maskLayer;


}
return self;

最佳答案

尝试这样的事情:

view.layer.cornerRadius = 5.0;
view.layer.masksToBounds = YES;

阴影:

view.layer.shadowColor = [UIColor blackColor].CGColor;
view.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
view.layer.masksToBounds = NO;
view.layer.shadowRadius = 5.0f;

确保导入<QuartzCore/QuartzCore.h>

关于ios - 创建圆角 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14647604/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com