UIImageVIew

来源:互联网 发布:linux的网络配置文件 编辑:程序博客网 时间:2024/05/05 04:41

属性

    //创建UIImageView    UIImageView * imageView = [[UIImageView alloc] initWithFrame:self.window.bounds];/---------------------属性----------------------/    //添加图片    imageView.image = [UIImage imageNamed:@"name"];    //图片模式    /***************************************     UIViewContentModeScaleToFill,     默认拉伸     UIViewContentModeScaleAspectFit,  按比例拉伸,不会造成形变     UIViewContentModeScaleAspectFill, 按比例铺满整个屏幕,造成变形    ***************************************/    imageView.contentMode =  UIViewContentModeScaleAspectFill;    //子视图是否接受点击事件,默认是NO    imageView.userInteractionEnabled = YES;

播放image动画

    //1:创建可变数组    NSMutableArray * imageArray = [[NSMutableArray alloc] init];    //2:循环读取图片    for (int i = 1; i <= 17; i++) {        //读取图片        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"campFire%02i.gif",i]];        //读出来的图片放进数组        [imageArray addObject:image];    }    //3:把图片数组添加到imageView进行播放    imageView.animationImages =imageArray;    //动画时长    imageView.animationDuration = 2;    //动画次数    imageView.animationRepeatCount = 100;    //开始动画    [imageView startAnimating];
0 0
原创粉丝点击