美文网首页
UI基础控件

UI基础控件

作者: 飞翔的鸵鸟 | 来源:发表于2016-02-23 10:43 被阅读16次

1.UILabel

文本内容                         text                                                            @"abc”

背景颜色                          backgroundColor                                    UIColor yellowColor

文本内容颜色                    textColor                                                 UIColor redColor

文本对齐方式                    textAlignment(枚举)                                NSTextAlignmentCenter

文本字体大小                    font                                                        UIFont systemFontOfSize:20

文本行数                           numberOfLines                                       0

自适应label尺寸                sizeToFit                                                 label sizeToFit

断行模式                           lineBreakMode                                       NSLineBreakByTruncatingMiddle

阴影颜色                           shadowColor                                          UIColor cyanColor

阴影大小                           shadowOffset                                         CGSizeMake(2, 1)

设置边框                           layer.borderWidth                                   1

设置圆角                           layer.cornerRadius                                 5

抹除圆角多余背景色         layer.masksToBounds                            YES

文本位置大小                    label.frame                                             CGRectMake(100, 100, 200, 200)

修改视图的位置                center                                                     CGPointMake(500, 175)

1.1创建UILabel

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 150)];

label.backgroundColor = [UIColor yellowColor];

[self.window addSubview:label];

[label release];


2.UIView

背景颜色                            backgroundColor            UIColor yellowColor

透明度                                 alpha                                  0.5

位置大小                            frame                                  CGRectMake(200, 100, 150, 150)

父视图把视图放在上面    bringSubviewToFront         view2

父视图把视图放在下面       sendSubviewToBack           view2

2.1创建UIView

UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];

view1.backgroundColor = [UIColor yellowColor];

[self.window addSubview:view1];

[view1 release];


3.UIButton

位置大小                            frame                      CGRectMake(100, 100, 150, 70)

背景颜色                             backgroundColor            UIColor cyanColor

标题                                    setTitle:   forState:      @“确认"    UIControlStateNormal

标题字体大小                     titleLabel.font            UIFont systemFontOfSize:25

圆角                                   layer.cornerRadius         10

边框                                   layer.borderWidth          1

点击方法             addTarget:  action:              forControlEvents:

self       @selector(click:)   UIControlEventTouchUpInside

背景图片                            setBackgroundImage:                   forState:

[UIImage imageNamed:@"checked.png"]    UIControlStateNormal

3.1创建UIButton

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];

button.frame = CGRectMake(100, 100, 100, 40);

[self.window addSubview:button];

[button setTitle:@"确认" forState:UIControlStateNormal];

button.layer.borderWidth = 1;

button.layer.cornerRadius = 10;

[button addTarget:self action:@selector(changePic:) forControlEvents:UIControlEventTouchUpInside];

[button setBackgroundImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];

-(void)changePic:(UIButton *)button{

}


4.UITextField

背景颜色                backgroundColor              UIColor cyanColor

边框                                            layer.borderWidth            1

圆角                                            layer.cornerRadius           10

文本内容                                     text                         @"abc"

占位文本                                     placeholder                  @"占位字符"

文本颜色                                     textColor                    UIColor yellowColor

文本位置                                     textAlignment                NSTextAlignmentCenter

密码圆点                                     secureTextEntry              YES

键盘类型                                     keyboardType                 UIKeyboardTypeNumberPad

return样式                               returnKeyType                UIReturnKeySearch

清除按钮样式                              clearButtonMode              UITextFieldViewModeAlways

弹出视图.默认是键盘                inputView                    view

辅助视图                                    inputAccessoryView           view

4.2创建UITextField

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 200,40)];

textField.backgroundColor = [UIColor cyanColor];

[self.window addSubview:textField];

[textField release];

textField.delegate = self;

-(BOOL)textFieldShouldReturn:(UITextField *)textField{

NSLog(@"测试return按钮");

//回收键盘   (改变第一响应者)

[textField resignFirstResponder];

return YES;

}

-(BOOL)textFieldShouldClear:(UITextField *)textField{

NSLog(@"测试清除按钮");

return YES;

}


相关文章

  • 第一行代码(2)UI设计

    1. 基础UI控件 Android中的基础UI控件有这样几种: TextView Button EditText ...

  • 第五章 Android 常见UI基础控件(一)

    这里主要讲讲新的Android 基础的UI控件,此外还拓展下新的控件。所有的控件都是View的子类。常见的UI控件...

  • Android学习线路—Android UI详解

    2.Android UI(User Interface)详解 2.3基础UI控件 2.3.15 CalendarV...

  • IOS-UI控件基础

    ++2016/7/11 ++by side @OC-UI控件基础 UI(user interface)介绍: U...

  • UI基础知识

    UI基础知识 控件相关 大部分UI控件都基于UIView,因此控件不仅具有一些自己独有的属性,还有UIView的属...

  • UI基础控件

    /*- - - - - - - - - - - - - - - - -UILabel - - - - - - - ...

  • UI控件基础

    iOS 学习资料整理写在前面-(学习背景)从去年开始就想跳入iOS开发的这个坑,从看C语言开始,到Objectiv...

  • UI基础控件

    1.UILabel 文本内容 text ...

  • UI基础控件

    一、UIView常见属性 1.frame 位置和尺寸(以父控件的左上角为原点(0,0)) 2.center 中点(...

  • UI基础控件

    //准备工作 1.删除Main 2.ARC->MRC(YES->No) 3.删除文件(ViewConTroller...

网友评论

      本文标题:UI基础控件

      本文链接:https://www.haomeiwen.com/subject/mwmbkttx.html