设置特定位置圆角时,可以用遮罩层来解决这个事情。Button和Label都可以,用贝塞尔曲线来画。不再赘述。但当边框颜色和背景色不一致时。可以添加一个sublayer来解决,我在这样做的过程中发现了一个有意思的现象,用button添加是没问题的。但是label这样做的时候,内容始终不显示,开始以为是盖住了,但是当我内容换了,又能显示了,后来发现内容只是英文或数字时,内容没有显示,而当内容中包含中文时又可以显示了。
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 84, 36) byRoundingCorners:UIRectCornerTopRight cornerRadii:CGSizeMake(1, 1)];
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
layer.path = path3.CGPath;
layer.frame = CGRectMake(0, 0, 84, 36);
layer.lineWidth = 0.5;
layer.fillColor = [[UIColor clearColor] CGColor];
layer.strokeColor = [[PTUtility colorWithHexString:@"999999"] CGColor];
[self.amount.layer addSublayer:layer];
仅以记录,有时间深究。