• ios 裁剪图片(1裁多)


    裁剪图片:(C类库方法)

    - (void)viewDidLoad {
        [super viewDidLoad];
        UIImageView *iv = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 60, 90)];
        [self.view addSubview:iv];
        
        //得到僵尸的完整图片
        UIImage *zombImage = [UIImage imageNamed:@"zomb_2"];
    
    //    ************截取单张图片
    //    截取里面的图片 CG开头
        CGImageRef subImage = CGImageCreateWithImageInRect(zombImage.CGImage, CGRectMake(0, 0, zombImage.size.width/8, zombImage.size.height));
    
    //    把CGImage转成 UIImage
        iv.image = [UIImage imageWithCGImage:subImage];
    
    
        //释放用完的CG图片
           CGImageRelease(subImage);
    
    //   *******************截取每一张
        NSMutableArray *images = [NSMutableArray array];
    
    //    0w 1w  2w  3w
        for (int i=0; i<8; i++) {
            CGImageRef imageRef = CGImageCreateWithImageInRect(zombImage.CGImage, CGRectMake(i*(zombImage.size.width/8), 0, zombImage.size.width/8, zombImage.size.height));
            [images addObject:[UIImage imageWithCGImage:imageRef]];
    
            //把用完的imageRef释放(CG...框架没有自动释放池,需要手动释放)
            CGImageRelease(imageRef);
        }
        //设置动画的代码
        [iv setAnimationImages:images];
        [iv setAnimationDuration:1];
        [iv setAnimationRepeatCount:0];
        [iv startAnimating];
        
    }
    
    成功的三大原则: 1、坚持 2、不要脸 3、坚持不要脸
  • 相关阅读:
    CentOS 7 安装java 环境
    CentOS 7 替换网易yum 源
    九度:题目1553:时钟
    Maximum Subarray
    职场细节
    poj2524 Ubiquitous Religions
    九度 1526:朋友圈
    程序载入
    设备管理
    操作系统系列
  • 原文地址:https://www.cnblogs.com/xulinmei/p/7420297.html
Copyright © 2020-2023  润新知