UI----安健1 button lable textfiend
//按钮
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect ];//按钮形状
button.frame = CGRectMake(50, 200, 50, 50);//大小
[button addTarget:self action:@selector(buttonlast) forControlEvents:UIControlEventTouchUpInside];//添加事件
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//按钮的字体靠左
button.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);//按钮的字体靠左有十个单位距离
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];//字体的颜色
button.backgroundColor = [UIColor yellowColor];//按钮颜色
[button setTitle:@"下一页" forState:UIControlStateNormal];//按钮的名字
[btn.layer setCornerRadius:10.0];//设置矩形四个圆角半径
[self.view addSubview:button];//添加到view上
button1 setBackgroundImage: forState:;//按钮的背景图片
[confirm setTitleColor:[UIColor redColor] forState:UIControlStateNormal];//设置按钮字体颜色
-(void)buttonlast {
1一个界面跳转到另一个界面
要跳转的界面 *view = [[要跳转的界面 alloc]init];
[self presentViewController:view animated:YES completion:nil];
2返回原先的页面
[ self dismissViewControllerAnimated: YES completion: nil ];
}
//lable
UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
[label setCenter:CGPointMake(150, 150)];
label.text = @"刀山火海将会是真正的英雄";
label.textColor = [UIColor redColor];
label.font = [UIFont systemFontOfSize:10];
label.backgroundColor = [UIColor clearColor];
label.numberOfLines = 0;//换行
label.textAlignment = NSTextAlignmentCenter;//对齐方式
[self.view addSubview:label];
//textfiend
UITextField *textfiend = [[UITextField alloc]init];//初始化
textfiend.frame =CGRectMake(20, 20, 200, 20);//大小
//设置字体颜色
text.textColor = [UIColor redColor];
//是否纠错
text.autocorrectionType = UITextAutocorrectionTypeNo;
[textfiend setBorderStyle:UITextBorderStyleRoundedRect];//边框
textfiend.keyboardAppearance = UIKeyboardAppearanceAlert;//键盘
textfiend.textAlignment = NSTextAlignmentCenter;
//设置输入框的背景颜色,此时设置为白色 如果使用了自定义的背景图片边框会被忽略掉
text.backgroundColor = [UIColor whiteColor];
//设置背景
text.background = [UIImage imageNamed:@"dd.png"];
//当输入框没有内容时,水印提示 提示内容为password
text.placeholder = @"password";
//设置输入框内容的字体样式和大小
text.font = [UIFont fontWithName:@"Arial" size:20.0f];
//输入框中是否有个叉号,在什么时候显示,用于一次性删除输入框中的内容
text.clearButtonMode = UITextFieldViewModeAlways;
//每输入一个字符就变成点 用语密码输入
text.secureTextEntry = YES;
//内容对齐方式
text.textAlignment = UITextAlignmentLeft;
//内容的垂直对齐方式 UITextField继承自UIControl,此类中有一个属性contentVerticalAlignment
text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
//设置为YES时文本会自动缩小以适应文本窗口大小.默认是保持原来大小,而让长文本滚动
textFied.adjustsFontSizeToFitWidth = YES;
//设置自动缩小显示的最小字体大小
text.minimumFontSize = 20;
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[text resignFirstResponder]; //主要是[receiver resignFirstResponder]在哪调用就能把receiver对应的键盘往下收
return YES;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
//返回一个BOOL值,指定是否循序文本字段开始编辑
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
//开始编辑时触发,文本字段将成为first responder
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
//返回BOOL值,指定是否允许文本字段结束编辑,当编辑结束,文本字段会让出first responder
//要想在用户结束编辑时阻止文本字段消失,可以返回NO
//这对一些文本字段必须始终保持活跃状态的程序很有用,比如即时消息
return NO;
}
- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
//当用户使用自动更正功能,把输入的文字修改为推荐的文字时,就会调用这个方法。
//这对于想要加入撤销选项的应用程序特别有用
//可以跟踪字段内所做的最后一次修改,也可以对所有编辑做日志记录,用作审计用途。
//要防止文字被改变可以返回NO
//这个方法的参数中有一个NSRange对象,指明了被改变文字的位置,建议修改的文本也在其中
return YES;
}
- (BOOL)textFieldShouldClear:(UITextField *)textField{
//返回一个BOOL值指明是否允许根据用户请求清除内容
//可以设置在特定条件下才允许清除内容
return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
//返回一个BOOL值,指明是否允许在按下回车键时结束编辑
//如果允许要调用resignFirstResponder 方法,这回导致结束编辑,而键盘会被收起[textField resignFirstResponder];
//查一下resign这个单词的意思就明白这个方法了
return YES;
}
[self.view addSubview:textfiend];
}
UI----安健1 button lable textfiend的更多相关文章
- 关于Unity中UI中的Button节点以及它的Button组件
Button是最常用的UI节点,包含的组件有 1.Image组件 显示Button的纹理,把Image贴图拖进Image组件中后,记得点击Set Native Size,显示贴图原始大小 2.Butt ...
- Cocos2d-x3.0 载入Cocostudio的UI后,button无法点击的解决方法
原帖地址:http://blog.csdn.net/musicvs/article/details/28390617 近期发现不少朋友都遇到这个问题,用Cocostudio的UI编辑器创建好UI后,在 ...
- Android UI 统一修改Button控件的样式,以及其它系统控件的默认样式
先介绍下修改原理:首先打开位于android.widget包下面的Button.java文件,这里有一句关键的代码如下: public Button(Context context, Attribut ...
- UI组件之Button
UIButton:按钮,可以实现用户和app的交互,父类是UIControl,事件驱动型的组件的父类都是UIControl.一般使用类方法创建一个对象,创建时指定button的类型, iOS7.0后采 ...
- 160908、前端开发框架Semantic UI
简介 网页开发中,CSS控制网页样式.作为测试开发工程师,我个人不太擅长手写CSS.样式微调.兼容浏览器等工作,所以我选择使用成熟的前端框架,可以快速开发出样式美观的网站,也解决了大部分浏览器兼容问题 ...
- unity区分点击在3D物体还是2D UI上
当场景中的3D物体需要响应点击,但同时有UI显示时,存在判断点击是在3D物体上还是UI上的问题,办法如下: 1. 射线检测所有2D 3D物体,有2D物体被检测到时表明当前有UI.但无论Physics2 ...
- Semantic UI中的验证控件的事件的使用
1.Semantic UI中的验证控件,功能挺不错的,中文官网的文档写的都比较详细了,我再这里就不再进行重复了,主要是想说一下它的事件的使用方法,这个可能有部分朋友刚开始接触的时候不太了解 注意看这几 ...
- GUI动态创建button
#include "cocos2d.h" #include "cocos-ext.h" USING_NS_CC; USING_NS_CC_EXT; using ...
- semantic UI first web
官方文档:https://semantic-ui.com/introduction/getting-started.html semantic UI: SemanticUI是一款语义化设计的前端开源 ...
随机推荐
- 利用Runtime给UITextView添加占位符(新方法)
以前一直使用自定义UITextView通过通知中心来自定义placeHolder,最近看到这个方法,感觉更好 UITextView *textView = [[UITextView alloc]in ...
- Python学习笔记——基础篇【第五周】——模块
模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能需要多个函数才 ...
- HUD 1171 Big Event in HDU(01背包)
Big Event in HDU Problem Description Nowadays, we all know that Computer College is the biggest depa ...
- spring 加载多个资源文件
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Prop ...
- [帖子收集]通用Windows平台(UWP)
通用Windows平台,universal windows platform,UWP 什么是通用 Windows 平台 (UWP) 应用?(微软MSDN) 如何在通用 Windows 平台应用中使用现 ...
- The certificate that was used has a trust chain that cannot be verified问题
今天调用wcf程序的时候发现证书有问题.报的错误如下 The certificate that was used has a trust chain that cannot be verified. ...
- python setup.py install 报错ImportError: No module named setuptools
学习光荣之路python课程时,使用python setup.py install安装其他模块时,第一次安装某模块成功了.安装另一模块却报错ImportError: No module named s ...
- Java swing 如何将一个按钮放置到弹出框框的任意位置?(Absolute layout 布局的使用)
准备: Absolute layout 绝对布局,绝对布局中控件的可以在任意位置放置 如何制作下面那种样子的 弹出框? ---------------------------------------- ...
- YII2.0 数据库增删改查
/*==================== dkhBaseModel 数据库增删改查方法 start ================================*/ //新增一条数据 publ ...
- Android: Failure [INSTALL_FAILED_DEXOPT] and Failure [INSTALL_FAILED_UID_CHANGED] 解决方案
1. 错误: Failure [INSTALL_FAILED_DEXOPT] Android安装App时 D:\WorkSpace\Administrator\workspace\svn\soot ...