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 ...
随机推荐
- net.sf.json 时间格式的转化
后台代码 //后台代码 response.setCharacterEncoding("UTF-8"); JsonConfig jsonConfig = new JsonConfig ...
- [Android]通过js方法回调部分native报错 Web Console: Uncaught TypeError: Object [object Object] has no method 'xxx'
在android4.2以前,注入步骤如下: webview.getSetting().setJavaScriptEnable(true); class JsObject { public String ...
- 【MySQL】InnoDB: Error: checksum mismatch in data file 报错
参考:http://www.jb51.net/article/66951.htm 用5.7版本启动原5.5实例后,再用5.5启动出现以下报错 InnoDB: Error: checksum misma ...
- <meta http-equiv="refresh" content="0; url=">是什么意思?
页面定期刷新,如果加url的,则会重新定向到指定的网页,content后面跟的是时间(单位秒),把这句话加到指定网页的<head></head>里一般也用在实时性很强的应用中, ...
- numpy.concatenate
import numpy as np a = np.array([[1, 2], [3, 4]]) a.shape Out[3]: (2, 2) b = np.array([[5, 6]]) b.sh ...
- Maven学习总结(二)——Maven项目构建过程练习
上一篇只是简单介绍了一下maven入门的一些相关知识,这一篇主要是体验一下Maven高度自动化构建项目的过程 一.创建Maven项目 1.1.建立Hello项目 1.首先建立Hello项目,同时建立M ...
- ajax实现文件下载
前台: <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> ...
- mysql批量执行sql文件
1.待执行的sql文件为1.sql.2.sql.3.sql.4.sql等 2.写一个batch.sql文件: source .sql; source .sql; source .sql; source ...
- 未在本地计算机上注册“OraOLEDB.Oracle.1”提供程序解决方案
未在本地计算机上注册“OraOLEDB.Oracle.1”提供程序解决方案 一.现象: C#程序中需要以Provider=OraOLEDB.Oracle.1方式访问ORACLE数据库.但程序执行时报 ...
- LR录制https协议报证书错误,导航已阻止
使用IE浏览器录制https协议报证书错误,导航已阻止,修改如下配置文件: