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 ...
随机推荐
- EXCL poi导入
public static void importExcel2(File file) throws Exception { InputStream is = new FileInputStream(f ...
- 浅析Linux下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc文件
转自:http://www.ahlinux.com/shell/20239.html 0x01 /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行,并从/e ...
- eclipse与myeclipse恢复已删除的文件和代码
1.类文件的恢复 选择项目后右键-->选择Restore from Local history-->出现下面的界面: 勾选后按Restore就恢复了,真的很强大很方便:但我没有就此罢手,我 ...
- jQuery MD5加密实现代码
$(md("你想要加密的字符串")); md5插件下载地址:http://xiazai.jb51.net/201003/yuanma/jquery_md5.rar 下面是我的简单例 ...
- create和grant配合使用,对Mysql进行创建用户和对用户授权
1.首先创建用户username以及密码passwd,授权主机localhost. create user ‘username’@'localhost' identified by 'passwd' ...
- 《C和指针(Pointer on c)》 学习笔记
转载:http://dsqiu.iteye.com/blog/1687944 首先本文是对参考中三个连接的博客进行的整理,非常感谢三位博主的努力,每次都感叹网友的力量实在太强大了…… 第一章 快速上手 ...
- 自动获取socket链接状态
C# TcpClient在连接成功后无法检测连接状态,即使对方关闭了网络连接.以下扩展可检测连接状态: static class TcpClientEx { public static bool Is ...
- Sql 邮件发送
select name from msdb.dbo.sysmail_profile --邮件发送日志 SELECT * FROM msdb.dbo.sysmail_event_log delete F ...
- A 浪哥的烦恼 完全背包dp
https://biancheng.love/contest-ng/index.html#/131/problems 首先,去到n点的最小时间是所有数加起来. 然后,如果我1 --- 2,然后再2-- ...
- (学习网址)Python 自动化测试
1.Python自动化测试地址 http://www.wtoutiao.com/author/python-selenium.html 2.unittest参考网址: 1)python自动化测试报告H ...