UILabel和UIButton
textLabel.backgroundColor = [UIColor colorWithRed:60/255.0 green:50/255.0 blue:300/255.0 alpha:1];
textLabel.lineBreakMode =NSLineBreakByCharWrapping;
textLabel.numberOfLines = 0;
textLabel.font = [UIFont systemFontOfSize:25];//设置字体的大小
label1.backgroundColor = [UIColor blueColor];
//对齐方式,默认的是左对齐
label1.textAlignment = NSTextAlignmentRight;//右对齐
label1.textAlignment = NSTextAlignmentLeft;//左对齐
text文本属性
//给对象设置内容
textColor文本颜色
font字体属性
label1.font = [UIFont boldSystemFontOfSize:20];//字体加租
lineBreakMode 断行模式
shadow属性
NSLineBreakByTruncatingHead
.adjustsFontSizeToFitWidth
UIButton
//设置文本颜色
//设置字体大小
//设置高亮
//以上偏移量的设置是为了让图片与文字有良好的视觉效果,用户可以根据需要自己设置
//设置文本颜色
//设置字体大小
//设置高亮
@interface ViewController (){
UILabel *_label;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.backgroundColor = [UIColor orangeColor];
button.frame = CGRectMake(170, 100, 50, 50);
[button addTarget:self action:@selector(buttonClicked1:) forControlEvents:UIControlEventTouchUpInside];
button.tag = 1;
[self.view addSubview:button];
UIButton *button1 = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button1.backgroundColor = [UIColor redColor];
button1.frame = CGRectMake(170, 180, 50, 50);
[button1 addTarget:self action:@selector(buttonClicked1:) forControlEvents:UIControlEventTouchUpInside];
button1.tag = 2;
[self.view addSubview:button1];
_label = [[UILabel alloc]initWithFrame:CGRectMake(190, 250, 50, 50)];
[self.view addSubview:_label];
_label.text= [NSString stringWithFormat:@"%zi",btn.tag];
NSLog(@"按钮%zi被点击",btn.tag);
}




button.frame = CGRectMake(170, 300, 80, 80);
//赋值
//添加事件
//添加图片
//设置图片位置
//添加到父视图
-(void)buttonClicked1{
NSLog(@"按钮被点击");


UILabel和UIButton的更多相关文章
- 1.注册或登录页面设计:UILabel,UIButton,UITextField
学习iOS开发已经有一段时日了,之前一直没有系统的对iOS开发的相关知识进行归纳总结,导致很多知识点云里雾里在脑子里形不成iOS开发的思想,现将自己在学习过程中遇到的一些知识进行总结,希望能对iOS初 ...
- iOS UILabel UITextView UIButton 等等显示文本行间距
iOS UILabel UITextView UIButton 等等显示文本行间距都用如下方法 NSMutableParagraphStyle *paragraphStyle = [[NSMutab ...
- iOS开发-UILabel和UIButton添加下划线
关于UILabel和UIButton有的时候需要添加下划线,一般有两种方式通过默认的NSMutableAttributedString设置,第二种就是在drawRect中画一条下划线,本文就简单的选择 ...
- UILabel和UIButton添加下划线
关于UILabel和UIButton有的时候需要添加下划线,一般有两种方式通过默认的 NSMutableAttributedString设置,第二种就是在drawRect中画一条下划线,本文就简单的选 ...
- iOS学习21之UILabel, UITextField, UIButton, UIImageView
1.UILabel 1> 概述 UILabel (标签): 是显示文本的控件.在App中 UILabel 是出现频率最高的控件 UILabel 是 UIView 子类,作为子类一般是为了扩充父类 ...
- UILabel,UITextField,UIButton三大基础控件总结
(一)UILabel空件 属性: 1.背景颜色 label.backgroundColor = [UIColor ***]; 2. 显示文字: label.text = @"******&q ...
- IOS UIlabel 、UIButton添加下划线
1.给UILabel 添加下划线 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(, , , )]; label.backgrou ...
- UILabel和UIbutton(富文本)封装方法
/** 方法说明:设置label的富文本属性 参数说明:contentStr富文本内容 textColor字体颜色 rangeSet设置字体颜色及大小的位置 */ - (UILabel *)backf ...
- 你真的了解UIButton、UILabel 吗?
一:首先查看一下关于UIButton的定义 @class UIImage, UIFont, UIColor, UIImageView, UILabel; //设置UIButton的样式 typedef ...
随机推荐
- 1,SFDC 管理员篇 - 基本设置
1, 公司配置 Setup | Administrator| Company Profile *Company Inforamtion:公司基础信息,License信息,重要的设置包括本地时间,币种, ...
- .NET 扩展方法
.NET 的扩展方法是在.NET 3.0引入的,MSDN给出的定义是:扩展方法使你能够向现有类型“添加”方法(包括你自定义的类型和对象噢),而无需创建新的派生类型.重新编译或以其他方式修改原始类型.扩 ...
- maximo功能修改笔记
经过前几次的简单的修改系统功能,对maximo的bean开发已经有了一定了解,现在是耗时近两个礼拜来修改了一项系统功能,所用到的知识 Bean Fld, 下面我认真总结修改功能过程中的学到的知识: 目 ...
- [已解决]EnvironmentError: mysql_config not found
$ pip install MySQL-python==1.2.5 报错: EnvironmentError: mysql_config not found 原因是缺少包 libmysqlclient ...
- JAVA的包装类 【转】
Java语言是一个面向对象的语言,但是Java中的基本数据类型却是不面向对象的,这在实际使用时存在很多的不便,为了解决这个不足,在设计类时为每个基本数据类型设计了一个对应的类进行代表,这样八个和基本数 ...
- 利用spring、cxf编写并发布webservice
配置文件spring-wsServer.xml <?xml version="1.0" encoding="UTF-8"?> <beans x ...
- GBDT基本理论及利用GBDT组合特征的具体方法(收集的资料)
最近两天在学习GBDT,看了一些资料,了解到GBDT由很多回归树构成,每一棵新回归树都是建立在上一棵回归树的损失函数梯度降低的方向. 以下为自己的理解,以及收集到的觉着特别好的学习资料. 1.GBDT ...
- JQuery之正则表达式
1.定义正则表达式 /.../ 用于定义正则表达式 /.../g 表示全局匹配 /.../i 表示不区分大小写 /.../m 表示多行匹配 2.匹配正则表达式 非全局模式,不分组 var patte ...
- 自定义控件TextView
public class defineTextView extends TextView { Context context; public defineTextView(Context contex ...
- 开发中用到的开源框架汇总(Updating)
SuperWebSocket SuperSocket NPOI 官网:http://npoi.codeplex.com/ 实例讲解:http://www.cnblogs.com/yutian/p/52 ...