
我已经尝试了这种方法和一些更多的方法。
那么一旦图像不动,一切都可以正常运行。
但在我的项目中,我总是移动我的图像。
如果我添加角半径或阴影,图像运动不再平滑。而且看起来很可爱!
那就是我调整图像大小的方式:
CGSize newSize = CGSizeMake(200*height/image.size.height,280);CGcolorSpaceRef colorSpace = CGcolorSpaceCreateDeviceRGB();CGContextRef context = CGBitmapContextCreate(nil,newSize.wIDth,newSize.height,8,colorSpace,kCGImageAlphaPremultiplIEdLast);CGContextClearRect(context,CGRectMake(0,newSize.height));CGContextDrawImage(context,newSize.height),image.CGImage);CGImageRef scaledImage = CGBitmapContextCreateImage(context);CGcolorSpaceRelease(colorSpace);CGContextRelease(context);UIImage *newImage = [UIImage imageWithCGImage: scaledImage];CGImageRelease(scaledImage);
我想知道一个很好的方式来调整我的形象,添加阴影,角半径,还有我的图像的顺利移动。
解决方法// Get your image somehowUIImage *image = [UIImage imagenamed:@"image.jpg"];// Begin a new image that will be the new image with the rounded corners // (here with the size of an UIImageVIEw) UIGraphicsBeginImageContextWithOptions(imageVIEw.bounds.size,NO,[UIScreen mainScreen].scale); // Add a clip before drawing anything,in the shape of an rounded rect [[UIBezIErPath bezIErPathWithRoundedRect:imageVIEw.bounds cornerRadius:10.0] addClip]; // Draw your image[image drawInRect:imageVIEw.bounds]; // Get the image,here setting the UIImageVIEw image imageVIEw.image = UIGraphicsGetimageFromCurrentimageContext(); // Lets forget about that we were drawing UIGraphicsEndImageContext();
尝试移动这个代码,据我记得,我一直使用这一点,使一个圆角的图像,你可以移动到目标。但它似乎规模很好…
总结以上是内存溢出为你收集整理的ios – UIImage与圆角全部内容,希望文章能够帮你解决ios – UIImage与圆角所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)