iOS:找到旋转和圆角视图的底部y坐标

时间:2018-08-14 10:54:06

标签: ios objective-c cgaffinetransform cashapelayer cgrect

我有一个UIView,里面有CALayer。我尝试直接在此层的底部添加UILabel。但是我找不到它的坐标。在屏幕快照v iew上,颜色为蓝色,层-白色,标签-红色。 第一个屏幕截图是它的工作方式,第二个屏幕截图是它的工作方式。

enter image description here enter image description here 标签位置:

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;
    }
}

0 个答案:

没有答案