I have a UIView
with CALayer
inside. And I try to add UILabel
directly at the bottom of this layer. But I can't find it's coordinates. On the screenshot view got a blue color, layer - white, label - red.
The 1st screenshot is how it works and the second one is how it should work.
CGFloat yPos = CGRectGetMaxY(view.frame) + CGRectGetHeight(labelHeight) / 2;
label.center = CGPointMake(CGRectGetMidX(view.frame), yPos);
View rotate:
view.transform = CGAffineTransformMakeRotation(object.tableRotate * M_PI/180);
Layer inside view:
self.circularLayer.frame = CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds));
I'm applying rounded corners with mask:
- (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;
}
}