IOS UI02UILabel,UITextField,UIButton,UIAlertView,delegate

UILabel,UITextField,UIButton,UIAlertView,delegate

UILabel

UILabel显示文本(字符串),UIView子类

1.创建 2.属性3.添加到父视图4.释放

初始化UIView方法:   - (id)initWithFrame:(CGRect)aRect  

属性 :  .1 backgroundColor 背景颜色

            .2 text  文字(字符串)

             .3textColor 文字颜色

             .4textAlignment字体对齐方法

    enum {

   NSTextAlignmentLeft = 0,

   NSTextAlignmentCenter = 1,

   NSTextAlignmentRight = 2,

   NSTextAlignmentJustified = 3,

   NSTextAlignmentNatural = 4,

};

typedef NSInteger NSTextAlignment;

 .5font字体

 UIFont的类方法: + (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize

.6numberOfLines设置lable显示的行数,默认1行;设置为0表示无限制

.7lineBreakMode换行模式

typedef NS_ENUM(NSInteger, NSLineBreakMode) { /* What to do with long lines */

    NSLineBreakByWordWrapping = 0,     /* Wrap at word boundaries, default */

    NSLineBreakByCharWrapping, /* Wrap at character boundaries */

    NSLineBreakByClipping, /* Simply clip */

    NSLineBreakByTruncatingHead, /* Truncate at head of line: "...wxyz" */

    NSLineBreakByTruncatingTail, /* Truncate at tail of line: "abcd..." */

    NSLineBreakByTruncatingMiddle /* Truncate middle of line:  "ab...yz" */

} NS_ENUM_AVAILABLE_IOS(6_0);

.8shadowColor阴影颜色

.9shadowOffset阴影大小

UIView方法:- (void)sizeToFit 适用视图


UITextField

继承:UIControl :UIView : UIResponder : NSObject

UITextField文本框(输入框):是控制文本输入和显示的控件

核心功能:文本显示   输入控制   外观配置

1.创建2.属性3.添加到父视图4.释放

初始化UIView方法:   - (id)initWithFrame:(CGRect)aRect  


属性:   .1 borderStyle边框样式

typedef NS_ENUM(NSInteger, UITextBorderStyle) {

    UITextBorderStyleNone,

    UITextBorderStyleLine,

    UITextBorderStyleBezel,

    UITextBorderStyleRoundedRect

};

.2placeholder占位符,框里没有字的时候显示

.3secureTextEntry密文输入BOOL默认NO

.4keyboardType键盘类型

.5returnKeyType,   设置器,该名

.6inputView输入视图,自定义键盘x,y无影响,width非0,hight自定义

.7inputAccessoryView输入视图的辅助视图

.8enabled是否允许输入,NO时不能输入

.9clearsOnBeginEditing是否开始输入的时候清空输入框的内容

.10clearButtonMode 右边显示的'X’清楚按钮

.11leftView输入框左视图

.12leftViewMode左视图的显示模式

.13rightView输入框右视图

.14rightViewMode右视图的显示模式

并继承了父类的属性:text,textColor,textAlignment,font等

UIButton


UIButton按钮:是响应用户点击的控件


继承:UIControl : UIView : UIResponder : NSObject




1.创建 2.属性3.为按钮添加点击事件4.添加按钮到父试图5.按钮无需释放(结构体)




初始化本类方法+ (id)buttonWithType:(UIButtonType)buttonType

设置button的图像

如果button的type是custom,设置的图像可以直接显示

如果button的type时system,设置的图像可能需要选择渲染方


方法:


- (void)setTitle:(NSString *)title forState:(UIControlState)state将标题设置为使用指定状态。



- (void)setImage:(UIImage *)image forState:(UIControlState)state设置用于指定的标题。

父类UIControl:- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents添加一个目标和行动为特定事件(或事件)内部分派表。(添加响应)

父类UIControl:- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents移除按钮的点击


titleForState 



NSString *normalTitle = [loginButton titleForState:UIControlStateNormal];获取指定状态下的标题

setTitleColor:forState:


[loginButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];设置指定状态下地颜色

 titleColorForState:


UIColor *normalTitleColor = [loginButton titleColorForState:UIControlStateNormal];获取指定状态下地标题颜色

setTitleShadowColor:forState:


[loginButton setTitleShadowColor:[UIColor redColor] forState:UIControlStateNormal];设置指定状态下地标题阴影颜色

titleShadowColorForState:


UIColor *normalTitleShadowColor = [loginButton titleColorForState:UIControlStateNormal];获取指定状态下地标题阴影颜色





父类属性:frame,backgroundColor,


UIAlertView提醒视图

初始化:- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...

[alertView show];

[alertView release];


UIColor颜色

+ (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)bluealpha:(CGFloat)alpha   三原色设置UIColor对象


UIImage影像

+ (UIImage *)imageNamed:(NSString *)图像对象与指定的文件名。


UIResponder响应

- (BOOL)resignFirstResponder 通知接收器,它被要求放弃地位第一响应者的窗口。

- (BOOL)becomeFirstResponder通知接收器,它即将成为第一响应者的窗口。

属性  

         .1  inputView  放入视图

         .2 inputAccessoryView  放入提醒视图


NSLog(@"%s",__FUNCTION__);//显示当前函数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值