ios - Circular UIView from nib with animated and non-animated changes -


i'd make custom view acts just uiview when make bounds, frame, or transform changes: if change these things assignment, change in single frame, if change them in uiview animation block, animate current state state set. i'd define view , it's subviews in ib, , set constraints there.

the following code works coming out of nib constraints, , sets bounds/frame/transform assignment (no animation). can't animation working right.

in particular, animation of mask layer seems go wrong. @ present (even though think layoutsubviews should handle matching view animation) mask jumps half view width/height, animates centered position animation proceeds.

@implementation bubbleview  + (instancetype)bubbleviewfromnib {     bubbleview *view = [[nsbundle mainbundle] loadnibnamed:@"bubbleview" owner:nil options:nil][0];     return view; }  // works - (void)setmaskimagename:(nsstring *)name {     self.maskview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:name]]; }  - (void)layoutsubviews {     [super layoutsubviews];      // current animation bounds     caanimation *anim = [self.layer animationforkey:@"bounds"];      [catransaction begin];     if(anim) {         // animating, apply same duration , timing function.         [catransaction setanimationduration:anim.duration];         [catransaction setanimationtimingfunction:anim.timingfunction];          self.maskview.frame = self.bounds;     }     else {         // not animating, should disable implicit animations.         [catransaction disableactions];     }      self.maskview.frame = self.bounds;     [catransaction commit]; } @end  // calling view controller  // code in block doesn't work [uiview animatewithduration:1 animations:^{     //b.transform = cgaffinetransformscale(b.transform, 1.4, 1.4);     b.frame = cgrectinset(b.frame, -30,-30); }];  // same code works fine without animation //b.frame = cgrectinset(b.frame, -30,-30); 

i got layoutsubviews idea here https://stackoverflow.com/a/25458725/1272965 , earlier question asked here https://stackoverflow.com/a/45356867/1272965 (which not animating when changing these props on simple assignment).

can me make uiview mask work view provided ios, maintaining constraints , changing frame either animated or not animated? thanks!


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -