博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UI学习第一篇 (控件)
阅读量:4606 次
发布时间:2019-06-09

本文共 2217 字,大约阅读时间需要 7 分钟。

1.label它是一个用来显示文本的控件 它是UIView的子类 

//下面了开始对label的属性作设置

    alabel.backgroundColor = [UIColorredColor];

    //text属性是给label添加显示文字

    alabel.text = @" your  supportsadafafff background execution, this method is called instead of applicationWillTerminate: when the user quits.";

    //设置文字对齐方式

   // alabel.textAlignment = NSTextAlignmentCenter;

    //设置label的字体

    alabel.font = [UIFontsystemFontOfSize:20];

    //设置字体颜色

    alabel.textColor = [UIColorredColor];

    //社之文本颜色

    alabel.textColor = [UIColorwhiteColor];

//社值label可以显示的行数

    alabel.numberOfLines = 0;//0不限制行数;

    alabel.adjustsFontSizeToFitWidth = YES;//该属性是控制字体的大小来适应label的深度,保证文字完整显示。

    //设置换行模式

    //设置阴影

    alabel.lineBreakMode = NSLineBreakByWordWrapping;

    alabel.shadowOffset = CGSizeMake(10, 0) ;

    alabel.shadowColor = [UIColorblueColor]

    [self.window addSubview: alabel];//将label添加到窗口上

    [alabel release];//因为是手动管理内存,对应初始化的alloc所以要release

2.UITextFiled 是一个显示文本,并可以输入的文本框的控件 它是UICotrol的子类 和UIButton一样都可以添加事件响应 ,但一般很少对其添加。

 UITextField * atextField = [[UITextFieldalloc]initWithFrame:CGRectMake(20, 200, 280, 40)];

    //社值textfiled的外观

    atextField.backgroundColor = [UIColorwhiteColor];

    //atextField.borderStyle = UITextBorderStyleNone;

    atextField.borderStyle = UITextBorderStyleBezel;

    //设置默认提示文字

    atextField.placeholder = @"请输入文字信息";

    atextField.keyboardAppearance = UIKeyboardAppearanceDark;

    atextField.Tag =123;//tag是view的属性,可以通过viewWithTag:123找到该view 

    //也可以在原有文字上编辑

 

        //设置键盘样式

   // atextField.keyboardType = UIKeyboardTypeNumberPad;

    atextField.keyboardType = UIKeyboardTypeURL;

    //设置是否首字母大写。

    atextField.autocapitalizationType = UITextAutocapitalizationTypeNone;

    //将输入框添加到窗口上

    [self.window addSubview:atextField];

    [atextField release];

 //设置编辑时清空已输入的内容

    atextField.clearsOnBeginEditing = YES;

    //设置右边的清空按钮

    atextField.clearButtonMode = UITextFieldViewModeAlways;

 //给textFiled对象设置代理对象,辅助textFiled来完成操作

    atextField.delegate = self;

 

 3.

 //输入框的视图设置

    atextField.inputAccessoryView = greenView;//给输入框添加输入附加视图(即在输入视图(默认键盘视图)的上面)

    [greenView release];

    [_titleLabel release];

   //设置输入框的输入视图默认是键盘

//    UIView *_blueView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 216)];

//    _blueView.backgroundColor =[UIColor blueColor];

//   // atextField.inputView = _blueView;

//    [_blueView release];

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/jidesky/p/3691505.html

你可能感兴趣的文章
2016012003+陈琦+散列函数的应用及其安全性
查看>>
Android 状态栏通知Notification、NotificationManager详解
查看>>
UIApplicationDelegate协议
查看>>
Jmeter测试dubbo接口填坑
查看>>
[zz]GDB调试精粹及使用实例
查看>>
数据库的创建和删除
查看>>
最简单的三层实例【插入据
查看>>
设计模式学习笔记——Prototype原型模式
查看>>
pom.xml里有红叉报错的解决办法
查看>>
Perl last和next的用法区别
查看>>
Selenium 管理 Cookies
查看>>
exceptionfunction[LeetCode]Permutations
查看>>
Linux(2)_常用命令2
查看>>
自定义分页
查看>>
[转]DELPHI——调试(1)
查看>>
JS秒数转成分秒时间格式
查看>>
xp_cmdshell 命令的开启与关闭,和状态查询
查看>>
Linux sudoers
查看>>
MySQL详解(18)-----------分页方法总结
查看>>
bzoj 4595 激光发生器
查看>>