Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: Resize CALayer sublayers in view [duplicate]

I have a UIView which has about 8 different CALayer sublayers added to its layer. If I modify the view's bounds (animated), then the view itself shrinks (I checked it with a backgroundColor), but the sublayers' size remains unchanged.

How to solve this?

like image 716
Geri Borbás Avatar asked Nov 26 '22 21:11

Geri Borbás


1 Answers

I used the same approach that Solin used, but there's a typo in that code. The method should be:

- (void)layoutSubviews {
  [super layoutSubviews];
  // resize your layers based on the view's new bounds
  mylayer.frame = self.bounds;
}

For my purposes, I always wanted the sublayer to be the full size of the parent view. Put that method in your view class.

like image 153
Chadwick Wood Avatar answered Nov 28 '22 10:11

Chadwick Wood