我有一个UIView
,里面有CALayer
。我尝试直接在此层的底部添加UILabel
。但是我找不到它的坐标。在屏幕快照v iew上,颜色为蓝色,层-白色,标签-红色。
第一个屏幕截图是它的工作方式,第二个屏幕截图是它的工作方式。
CGFloat yPos = CGRectGetMaxY(view.frame) + CGRectGetHeight(labelHeight) / 2;
label.center = CGPointMake(CGRectGetMidX(view.frame), yPos);
旋转视图:
view.transform = CGAffineTransformMakeRotation(object.tableRotate * M_PI/180);
图层内部视图:
self.circularLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds));
我正在用蒙版应用圆角:
- (void)makeOval
{
CAShapeLayer *mask = [self shapeMaskLayer];
CGRect bounds = self.circularLayer.bounds;
if (!CGRectEqualToRect(mask.frame, bounds)) {
mask.frame = bounds;
mask.path = CGPathCreateWithEllipseInRect(bounds, nil);
}
}
- (CAShapeLayer *)shapeMaskLayer
{
if (self.circularLayer.mask && [self.circularLayer.mask isKindOfClass:[CAShapeLayer class]]) {
return (CAShapeLayer *)self.circularLayer.mask;
} else {
CAShapeLayer *layer = [CAShapeLayer layer];
layer.fillColor = [UIColor blackColor].CGColor;
self.circularLayer.mask = layer;
return layer;
}
}