我是iOS新手,在curve UIView方面面临问题。我想在图像中这样弯曲UIView顶部的半径
正如你所看到的我的工作视图截图。
我正在使用这样的代码
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:ViewSwapMyWork.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(70, 70) ]; CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = ViewSwapMyWork.bounds; maskLayer.path = maskPath.CGPath; ViewSwapMyWork.layer.mask = maskLayer;
首先,你的视图应该具有相同的高度和宽度,这意味着它应该是方形的,然后你可以这样做,
[ViewSwapMyWork.layer setCornerRadius:ViewSwapMyWork.frame.size.width/2]; [ViewSwapMyWork.layer setMasksToBounds:YES];