iOS开发(7)通过uiimageView浅谈UIView
来源:互联网 发布:建造者模式java 编辑:程序博客网 时间:2024/06/15 18:49
基本上,每一个IOS控件都有自己的VIew,View就是显示到屏幕上的视图。而屏幕就相当于显示各种View的容器。就好像是一个画家在自己的画布上写东西,很有意义把? 一个画家要想画出漂亮的东西就需要各种不同的画笔,就相当于UIView的各种属性,所以充分了解研究UIView的.h文件是很重要的。
@property(nonatomic,getter=isUserInteractionEnabled)BOOL userInteractionEnabled; // default is YES. if set to NO, user events (touch, keys) are ignored and removed from the event queue.
@property(nonatomic) NSInteger tag; // default is 0
@property(nonatomic,readonly,retain) CALayer *layer; // returns view's layer. Will always return a non-nil value. view is layer's delegate
@property(nonatomic)CGRect frame;
// use bounds/center and not frame if non-identity transform. if bounds dimension is odd, center may be have fractional part
@property(nonatomic)CGRect bounds; // default bounds is zero origin, frame size. animatable
@property(nonatomic)CGPoint center; // center is center of frame. animatable
@property(nonatomic)CGAffineTransform transform; // default is CGAffineTransformIdentity. animatable
以上只是列出部分常用的UIView的属性,绝大部分基本就够用了。以下请由我逐一介绍
1.userInteractionEnabled
该View是否能够交互,比如说在一个UIImageView的图片上面添加一个可点击的按钮,如果这个属性不设为YES,屏幕是不会感应到按钮被点击的。
2.tag
这是一个视图的标签。例如上一节中的UIImageView *uiv.
uiv.tag = 1;
在不把控件声明为全局变量的情况下,我们可以通过一个UIView的viewWithTag方法得到这个uiv。
UIImageView *i = [self.viewviewWithTag:1];
如果这样写会有一个报错,ncompatible pointer types initializing 'UIImageView *' with an expression of type 'UIView *' 原因就是UIView不能识别这个tag的类型,所以需要强转为自己需要的类型。UIImageView *i = (UIImageView *)[self.viewviewWithTag:1];
3.layer
这是一个很重要的也是很特殊的东西,layer层就相当于View背后的一个层,View的作用只是在Controller中显示,而真正决定View显示的内容就是这个layer层。
比如说给UIImageView设置圆角就在这个layer层
[uiv setMasksToBounds:YES];//打开边框布景开关
[uivsetCornerRadius:25];//设置圆角半径
4.frame
UIview显示的范围
5.bounds
UIView的边框
6.center
UIview的中心坐标
7.transform
这又是一个很重要的属性。转换属性。
以上可以看到一些基本的旋转,缩放。
以上只是根据个人平时的研究泛泛的介绍一下UIView.h文件里面常用的属性。至于更多的需要的东西,大家可以没事的时候研究一下。如果不当之处,还望高手指正。
- iOS开发(7)通过uiimageView浅谈UIView
- ios开发 UIView(UIImageView)添加六边形的遮罩
- ios开发(6)uiimageView
- iOS学习笔记(4)UIView和UIImageView
- ios-day18-02(通过CALayer做出跟UIImageView一样的效果、UIView和CALayer如何选择)
- iOS study_seventh (Uiview ,UiImageView,UiprogressView,Uislider,Uiswitcher)
- iOS将UIView转换成UIImageView
- IOS开发(17)之UIImageView控件
- iOS开发-UIImageView
- iOS开发 ----- UIImageView
- iOS开发之UIImageView
- UIVIew进阶-常用控件(三):UIImageView
- IOS开发----UIImageView 和 UIButton
- Swift开发IOS-UIImageView
- iOS开发UIImageView动画效果
- iOS开发:UIImageView常用操作
- IOS界面开发之UIImageView
- iOS开发 UIImageView的分类
- STM32_APIO 复用(转)
- Merge Sorted Array
- 统计元音(杭电2027)
- Vijos P1025 小飞侠的游园方案(01背包)
- C++ 虚函数表解析
- iOS开发(7)通过uiimageView浅谈UIView
- 黑马程序员--- 学习笔记(第十三天)
- RMAN参考使用手册2
- ORACLE中小数点问题的处理
- 设计模式学习笔记--门面(Facade)模式
- 8函数-最大公约数最小公倍数
- Java注解annotation用法和自定义注解处理器
- Eclipse 快捷键的运用
- Java I/O(一)--字节流,字符流