ios 图片缩放 失真

失真用红色代码起作用:




        UIImageView *_lockImage = (UIImageView *)[cell.contentView viewWithTag:lockTag];



        UIImage *image = [UIImage imageNamed:@"lock.png"];

        CGSize size=image.size;     

         //UIGraphicsBeginImageContext(size);  如果用这个就失真

         UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);

        [image drawInRect:CGRectMake(0, 0, size.width/1.5, size.height/1.5)];//缩放比例

        

        UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

  


        _lockImage.image=scaledImage;

      // _lockImage.contentMode = UIViewContentModeScaleAspectFit; //不起作用

        


你可能感兴趣的:(IOS)