daily pastebin goal
85%
SHARE
TWEET

Untitled

a guest Jan 12th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Resizing UIImageView clips sublayer
  2. - (id)initWithFrame:(CGRect)frame
  3. {
  4.     self = [super initWithFrame:frame];
  5.     if (self) {
  6.         small_ = frame;
  7.         float newX = self.center.x - ((self.frame.size.width*SELECTED_SCALE_VALUE)*0.5);
  8.         float newY = self.center.y - ((self.frame.size.height*SELECTED_SCALE_VALUE)*0.5);
  9.         big_ = CGRectMake(newX, newY, self.frame.size.width*SELECTED_SCALE_VALUE, self.frame.size.height*SELECTED_SCALE_VALUE);
  10.  
  11.         [self setupSubviews];
  12.     }
  13.     return self;
  14. }
  15.  
  16. - (void)setupSubviews
  17. {
  18.     shadowImage_ = [[UIImage imageNamed:@"gallery_shadow_frame"] resizableImageWithCapInsets:UIEdgeInsetsMake(20, 20, 20, 20)];
  19.     shadowImageView_ = [[UIImageView alloc] initWithFrame:[self shadowFrame]];
  20.     shadowImageView_.image = shadowImage_;
  21.     shadowImageView_.backgroundColor = [UIColor blueColor];
  22.     [self.layer insertSublayer:[shadowImageView_ layer] atIndex:0];
  23. }
  24.    
  25. - (void)makeBig
  26. {
  27.     self.frame = big_;
  28.     // shadowImageView_.frame = [self shadowFrame];
  29. }
  30.  
  31. - (void)makeSmall
  32. {
  33.     self.frame = small_;
  34.     // shadowImageView_.frame = [self shadowFrame];
  35. }
  36.    
  37. - (CGRect)shadowFrame
  38. {
  39.     int x = -X_BORDER;
  40.     int y = -Y_BORDER;
  41.     int width = self.frame.size.width + X_BORDER * 2;
  42.     int height = self.frame.size.height + Y_BORDER * 2;
  43.     return CGRectMake(x, y, width, height);
  44. }
  45.    
  46. self.layer.masksToBounds = NO;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top