objective c - View lose cornerRadius with Animation of UIViewAnimationOptionTransitionFlipFromLeft on iOS 8 -
in code, have set:
imageview.layer.maskstobounds = yes; imageview.layer.cornerradius = imageview.frame.size.width/2;
and run in animation block:
[uiview transitionwithview:imageview duration:1.0 options:uiviewanimationoptiontransitionflipfromleft animations:nil completion:^(bool finished) { imageview.hidden = yes; }];
but when running on ios 8, imageview
normal, means there no cornerradius
imageview
.
could tell me why?
you need slash corners of uiimage
not uiimageview
using calayer
using below code.
// load image on imageview programmatically uiimage *image = [uiimage imagenamed:@"yourimage.png"]; // assign changes reflected using method before load image imageview image = [self makeroundedimage:image radius:_imageview.frame.size.width/2]; _imageview.image = image;
// method create round image -(uiimage *)makeroundedimage:(uiimage *) image radius: (float) radius{ calayer *imagelayer = [calayer layer]; imagelayer.frame = cgrectmake(0, 0, image.size.width, image.size.height); imagelayer.contents = (id) image.cgimage; imagelayer.maskstobounds = yes; imagelayer.cornerradius = radius; uigraphicsbeginimagecontext(image.size); [imagelayer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *roundedimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return roundedimage; }
now can apply animation simply.
Comments
Post a Comment