UILabel, UITextField, UIImageView
来源:互联网 发布:程序员招聘要求 编辑:程序博客网 时间:2024/05/17 23:47
UILabel:
NS_CLASS_AVAILABLE_IOS(2_0) @interface UILabel : UIView <NSCoding>
UILabel 继承自 UIView, 这意味着UILabel可以使用UIView所拥有的属性和方法, 通常使用UIView类的初始化方法
UILabel中常用的属性:
@property(nonatomic,copy) NSString *text; —>UILabel对象中的文本
@property(nonatomic,retain)UIFont *font; —>UILabel对象中文本的字体
@property(nonatomic,retain)UIColor *textColor; —>UILabel对象中文本的颜色
@property(nonatomic,retain)UIColor *shadowColor; —> UILabel对象中文本阴影的颜色,默认为nil(无阴影)
@property(nonatomic) CGSize shadowOffset;
@property(nonatomic) NSTextAlignment textAlignment; —> 对齐方式
@property(nonatomic) NSLineBreakMode lineBreakMode; —> 省略方式
@property(nonatomic)NSIntegernumberOfLines; —> 断行数, 0为没有限制, 以UILabel对象实际宽和高位界限 this determines the number of lines to draw and what to do when sizeToFit is called
注: 调用sizeToFit方法和设numberOfLines的先后顺序不同结果也是不一样的. 应该先设numberOfLines = 0, 再调用sizeToFit方法.
UITextField:
NS_CLASS_AVAILABLE_IOS(2_0) @interface UITextField : UIControl <UITextInput, NSCoding>
继承关系: UITextField : UIControl :UIView : UIResponder : NSObject
通常使用UIView类的初始化方法
UITextField中常用的属性:
@property(nonatomic,copy) NSString *text; —> 属性意味着: 不仅可以赋值,还可以取值
@property(nonatomic,copy) NSAttributedString *attributedTextNS_AVAILABLE_IOS(6_0);
@property(nonatomic,retain)UIColor *textColor;
@property(nonatomic,retain)UIFont *font;
@property(nonatomic) NSTextAlignment textAlignment; —> 对齐方式
@property(nonatomic) UITextBorderStyle borderStyle;
@property(nonatomic) BOOL clearsOnBeginEditing; —> 再次编辑是清空, YES为点击是清空, NO为点击时光标放在点击处, 默认为NO
@property(nonatomic,copy) NSString *placeholder; —> 占位字符串,没有任何输入时,给出的提示字符串
UIImageView:
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIImageView : UIView
UIImageView继承自UIView.
UIImageView中常用的属性:
@property(nonatomic,retain)UIImage*image;
@property(nonatomic,retain)UIImage*highlightedImage NS_AVAILABLE_IOS(3_0);
UIImageView的初始化方法:
- (instancetype)initWithImage:(UIImage*)image;
- (instancetype)initWithImage:(UIImage*)image highlightedImage:(UIImage*)highlightedImageNS_AVAILABLE_IOS(3_0);
initWithImage需要一个UIImage类型的对象作为参数. UIImage可以用其便利构造器imageWithContentsOfFile:得到一个图片.
可以理解为: UIImage得到一个图片, 而UIImageView是装该图片的容器.
UIImage:
定义一个UIImage对象:
NSString*imageName = @"图片名”; —> 获得文件名
NSString*imagePath = [[NSBundlemainBundle]pathForResource:imageNameofType:@"png”]; —> 获得路径
UIImage*aImage = [UIImageimageWithContentsOfFile:imagePath]; —> 通过路径得到图像
注意 imageWithContentsOfFile: 和方法的区别 imageNamed:
- imageWithContentsOfFile: —> This method does not cache the image object.
- imageNamed: —> This method looks in the system caches for an image object with the specified name and returns that object if it exists.
所以 imageNamed: 加载时会缓存图片, 如果频繁引用一张图片, 则效率会比较高; imageWithContentsOfFile: 不会将图片缓存到内存, 因此遇到大图片时用这个方法会更加省内存.
0 0
- UIButton,UIImageView,UILabel,UITextField
- UILabel, UITextField, UIImageView
- UILabel,UITextField,UIButton,UIimageView
- UILabel、UITextField、UIButton、UIImageView控件
- UIView UILabel UITextField UIButton UIImageView 常用属性
- iOSDay21之UILabel, UITextField, UIButton, UIImageView
- UI-基本控件( UILabel UITextField UIImageView UIButton)
- 基础控件之UILabel、UIButton、UITextField、UIAlertView、 UIImageView
- UILabel UITextField
- iOS个人整理06-第一周小结,常用控件UIView,UILabel,UIImageView,UIButton,UITextField
- IOS开发UI系列之常用控件 UILabel, UITextField, UIButton, UIImageView等常用属性与方法
- iOS基础——UI控件之UIView、UITextField、UILabel、UIColor、UIButton、UIImageView
- UILabel+UIImageView(动画)
- UILabel和UITextfield详解
- UILabel 与 UITextField
- UILabel 和UITextfield详解
- UITextField、UILabel、UIButton
- UILabel, UITextField, UIButton
- javaSocket传输模式
- js知识点
- 【Jason's_ACM_解题报告】Defense Lines
- 2014,就这样按部就“班”走过
- 平凡设计空间下四中基本EDP
- UILabel, UITextField, UIImageView
- 网络编程——UDP Socket
- JavaEE中的事务管理——容器托管的事务
- JavaEE中的事务管理——bean托管的事务
- HDOJ 1108 最小公倍数(水)
- RTB中的cookie mapping理解
- swift UI专项训练24 构建函数和侦测网页载入事件
- [并发并行]_[C/C++]_[使用线程本地存储Thread Local Storage(TLS)-win32线程和pthread线程比较]
- Linux命令——rm