UIImageView的使用
来源:互联网 发布:mac mini忘记开机密码 编辑:程序博客网 时间:2024/06/03 16:44
//创建imageView
UIImageView *imgView = [[UIImageViewalloc] initWithFrame:CGRectMake(100,100, 200, 280)];
imgView.backgroundColor = [UIColorredColor];
//设置显示的图片,默认后缀名是png
UIImage *image = [UIImageimageNamed:@"1"];
imgView.image = image;
//设置高亮状态下显示的图片
imgView.highlightedImage = [UIImageimageNamed:@"scene1.jpg"];
// imgView.highlighted = YES;
//边框加工
imgView.layer.borderWidth =1;
imgView.layer.borderColor = [UIColorgreenColor].CGColor;
imgView.layer.cornerRadius =5;
//设置图片的填充模式UIViewContentModeScaleAspectFit:图片等比例拉伸
imgView.contentMode =UIViewContentModeScaleAspectFit;
[_window addSubview:imgView];
// imgView.animationImages =
NSMutableArray *imgArray = [[NSMutableArrayalloc] init];
for (int i=1; i<22; i++) {
NSString *imgName = [NSStringstringWithFormat:@"%d.jpg",i];
UIImage *img = [UIImageimageNamed:imgName];
//设置UIImage的图片拉伸点
//img resizableImageWithCapInsets:UIEdgeInsetsMake(距上,距左, 距下, 距右);
[imgArray addObject:img];
}
//设置imgView的动画集合
imgView.animationImages = imgArray;
//设置动画的时间
imgView.animationDuration =5;
//开始动画
[imgView startAnimating];
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeContactAdd];
button.frame = CGRectMake(20, 20, 20, 20);
[button addTarget:selfaction:@selector(buttonAction)forControlEvents:UIControlEventTouchUpInside];
[imgView addSubview:button];
//注意,在UIImageView添加点击事件时一定要改为yes
imgView.userInteractionEnabled =YES;
return YES;
}
- (void)buttonAction {
NSLog(@"按钮被点击了");
}
- UIImageVIew的使用
- UIImageView的使用
- UI UIImageView的使用
- UIImageView的使用
- UIImageView的使用
- iOS UIImageView 的使用
- UIImageView的使用
- UIImageView的使用
- iOS UIImageView的简单使用
- UIImageView 使用图片的用法
- UILabel和UIImageView的使用
- 使用UIImageView的画线方法
- swift中UIImageView的使用
- swift中UIImageView的使用
- ios中UIImageView的使用
- UIImageView 使用
- 使用UIImageView展现来自网络的图片
- 使用UIImageView展现来自网络的图片
- Lua的内存监测和回收
- java小题
- Android Permission
- Hibernate多对一关联映射
- 谷歌C++风格拾遗
- UIImageView的使用
- Android实现透明的颜色效果
- 【ExtJs】模态确定框与模态输入框
- 5个孩子的妈考进哈佛 她用半年的时间做到了
- 集电极开路、漏极开路、上拉电阻、下拉电阻等接口相关基本概念
- SD卡学习笔记二
- linux 命令系列之 usermod 和 chage(26)
- UISlider的使用
- web.xml配置错误页面