ios图片的保存修改等处理方法

2025-05-09 01:17:33

1、等比缩放- (UIImage *) scaleImage:(UIImage *)image toScale:(float)scaleSize {UIGraphicsBeginImageContext(CGSizeMake(image.size.width * scaleSize, image.size.height * scaleSize);[image drawInRect:CGRectMake(0, 0, image.size.width * scaleSize, image.size.height * scaleSize)];UIImage *scaledImage= UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();returnscaledImage;}

ios图片的保存修改等处理方法

3、处理某个特定的view只要是继承UIView的object 都可以处理必须先import QuzrtzCore.framework-(UIImage*) captureView:(UIView *)theView {CGRect rect = theView.frame;UIGraphicsBeginImageContext(rect.size);CGContextRef context = UIGraphicsGetCurrentContext();[theView.layer renderInContext:context];UIImage *img = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();returnimg;}

ios图片的保存修改等处理方法

5、UILabel根据text自动调整大小label.text = @"**********";CGRect frame = label.frame;frame.size.height = 10000;// 设置一个很大的高度label.frame = frame;[label sizeToFit];frame.size.height = label.frame.size.height;label.frame = frame;

ios图片的保存修改等处理方法ios图片的保存修改等处理方法
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢