I have read several posts already. And almost everyone suggest using QuartzCore/QuartzCore.h
with layer.cornerRadius
I have tried this method and some more methods.
Well, everything works fine when an image doesn't move.
But in my project I always move my images.
If I add corner radius or a shadow the image movement is no longer smooth. And it looks aweful!
That is the way I resize my image:
CGSize newSize = CGSizeMake(200*height/image.size.height, 280);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(nil, newSize.width, newSize.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast);
CGContextClearRect(context, CGRectMake(0, 0, newSize.width, newSize.height));
CGContextDrawImage(context, CGRectMake(0, 0, newSize.width, newSize.height), image.CGImage);
CGImageRef scaledImage = CGBitmapContextCreateImage(context);
CGColorSpaceRelease(colorSpace);
CGContextRelease(context);
UIImage *newImage = [UIImage imageWithCGImage: scaledImage];
CGImageRelease(scaledImage);
I would like to know a good way to resize my image, add shadow, corner radius and still have smooth movement of my image.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…