UIImageView 基本操作

UI_UIImageView 常用方法// 使用ImageView 通过 name 找到图片UIImage *image = [UIImage imageNamed:@”bg_2″];// 添加 image 到 imageView 上UIImageView *imageView = [[UIImageView alloc] initWithImage:image];// 设置图片位置和大小imageView.frame = CGRectMake(40, 40, 90, 160);imageView.backgroundColor = [UIColor redColor];// 设置透明度imageView.alpha = 0.5;// 为图片添加点击事件// userInteractionEnabled 为 YES ,,才能响应点击事件imageView.userInteractionEnabled = YES; // 设置图片可以交互// 设置手势UITapGestureRecognizer *singleTag = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)];// 添加手势[imageView addGestureRecognizer:singleTag];// 显示/隐藏 YES 为隐藏imageView.hidden = NO;// 获取网络中的图片UIImage *netImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@”www.google.com”]]];// 将 image 添加到 window 上,并释放内存[self.window addSubview:imageView];[imageView release];imageView = nil; // 安全释放动态图 UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”1.tiff”]];imageView.frame = CGRectMake(40, 50, 100, 100);// 把一组图片加到 imageView 上面NSMutableArray *array = [NSMutableArray array];for (int i = 1; i < 5; i++) {*image = [UIImage imageNamed:[NSString stringWithFormat:@”%d.tiff”, i]];[array addObject:image];}// 把数组放到imageView中imageView.animationImages = array;[self addSubview:imageView];// 播放时间imageView.animationDuration = 0.4f;// 播放次数imageView.animationRepeatCount = 0; // 0 就是无限次// 开始动画[imageView startAnimating];// 结束动画】// [imageView stopAnimating];

画龙画虎难画骨,知人知面不知心。

UIImageView 基本操作

相关文章:

你感兴趣的文章:

标签云: