UI之button基础
来源:互联网 发布:辐射4导入捏脸数据 编辑:程序博客网 时间:2024/05/21 06:41
UIButton->UIControl->UIView->UIResponder->NSObject//继承关系
系统样式:
UIButton * btn=[UIButtonbuttonWithType:UIButtonTypeCustom];
btn.frame=CGRectMake(100, 100, 100, 100);
[btn setTitle:@"文字"forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blueColor]forState:UIControlStateHighlighted];
btn.titleLabel.font=[UIFontsystemFontOfSize:22];//字体
[btn setTitleShadowColor:[UIColor redColor]forState:UIControlStateHighlighted];//阴影高亮
btn.currentTitle;//拿到当前标题
btn.currentTitleColor;//拿到标题颜色
btn.currentTitleShadowColor;//阴影颜色
自定义样式:
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(100, 220, 100,100);
UIImage * image=[UIImageimageNamed:@"xx.jpg"];//用这种方式创建图片,图片会在内存中缓存一次,消耗内存比较大,而且释放是比较困难的事情,同一个图片只会缓存一次,这种方式适合拿比较小的图片或则可能频繁使用的图片
[button setBackgroundImage:imageforState:UIControlStateNormal];//设置button背景图片,图片会铺满整个button,图片不够大会变形
[button setImage:[UIImageimageNamed:@"xxx.jpg"] forState:UIControlStateNormal];//设置前景图片;如果足够大,会显示图片原本的尺寸,而且会现在button的正中间
button.selected=YES;//设置button已经被点击,默认是no
button.enabled=NO;//设置button不能被点击,默认是yes
NSString * path=[[NSBundlemainBundle]pathForResource:@"guo" ofType:@"jpg"];//单例类,这种方式拿图片图片不会缓存,效率低,安全性高。
UIImage *image = [[UIImagealloc]initWithContentsOfFile:path];//读取图片
UIImageView->UIView;
imageView.contentMode =UIViewContentModeScaleToFill;//图片内容布局方式;
imageView.animationImages = birdArr;//把一组图片作为imageView一组动画图片
imageView.animationDuration = 0.5;//动画持续的时间(秒)
imageView.animationRepeatCount = 0;//动画重复的次数 0 表示一直重复
[imageView startAnimating];//启动动画
[imageView stopAnimating];//停止动画
- UI之button基础
- iOS开发之UI基础--Button基础
- Android基础UI控件之Button
- unity基础UI-Button
- IOS学习之iOS开发UI篇—Button基础
- UI基础----常见控件的使用之Button
- android ui之Button
- iOS开发 UI Button基础
- UI基础第二弹:Button基础
- Android UI 详解之Button
- cocos2dx 3.6 UI 之 Button
- Android UI学习之---Button
- swift之Button基础
- iOS开发UI篇—Button基础
- iOS开发UI篇—Button基础
- iOS开发UI篇—Button基础
- iOS开发UI基础—01Button
- iOS开发UI篇—Button基础
- LinkedHashSet 源代码
- Git上手(3)基础操作
- jms基础
- h5和原生页面之间的交互一(判断web页面是否在App中打开)
- 软件工程(C编码实践篇)学习总结
- UI之button基础
- 软件工程(C编码实践篇)学习总结
- springmvc整合mybatis遇到的问题
- Extra-terrestrial Intelligence
- 仿射变换及OpenCV实现
- 离散余弦变换DCT(Discrete Cosine Transform)
- Js中字符串的连接
- 【BZOJ1012】[JSOI2008]最大数maxnumber
- 贪心法:乘船问题