I have a UIView who's size depends on the objects inside of it. However, when I attempt to retrieve the bounds of the UIView's layer, it returns the original size before it resized. Here's the code:
- (void) viewWillAppear:(BOOL)animated {
[self.creditCount setText:@"This is a very long string"];
[self.creditCount sizeToFit];
CALayer *layer = self.creditCountView.layer;
layer.shadowOffset = CGSizeMake(1, 1);
layer.shadowColor = [[UIColor blackColor] CGColor];
layer.shadowRadius = 4.0f;
layer.shadowOpacity = 0.80f;
layer.shadowPath = [[UIBezierPath bezierPathWithRect:layer.bounds] CGPath];
}
In the code, creditCount is the text inside the view that resizes, and self.creditCountView is the view.
In Interface Builder:
When running:
Thanks in advance.
I fixed it by putting the code that applies the shadow in the "viewDidLayoutSubviews" event. That way, every time the size changes, the shadow updates.