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 ...
随机推荐
- JS动态获取数据
JS访问数据,有实时获取数据的时候,请加上时间戳 如:'&stampflag=' + Math.round(new Date().getTime() / 1000); 因为有的浏览器(如IE9 ...
- Python自动化 【第六篇】:Python基础-面向对象
目录: 面向过程VS面向对象 面向对象编程介绍 为什么要用面向对象进行开发 面向对象的特性:封装.继承.多态 面向过程 VS 面向对象 面向过程编程(Procedural Programming) ...
- C#调用C++的dll
在类中添加引用 using System.Runtime.InteropServices; 在程序中写 //关闭连接 [DllImport("opapi2.dll", EntryP ...
- VirtualBox 内的 Ubuntu Server 虚拟机网络配置
环境: 宿主机:Windows 7,单网卡: 虚拟机:ubuntu-14.04.1-server-amd64: 宿主机上网是连接的路由器,IP 地址是通过 DHCP 服务自动获取的: 基本情况: Ub ...
- git撤销commit
请参考该文章:http://www.cnblogs.com/ningkyolei/p/5026011.html 场景: 不小心commit了一个不应该commit的修改,但是还没有push,想撤销那个 ...
- [Swift]基础
[Swift]基础 一, 常用变量 var str = "Hello, playground" //变量 let str1="Hello xmj112288" ...
- Origin9.1如何绘制风向玫瑰图(Binned Data)?
Origin9.1如何绘制风向玫瑰图(Binned Data)? 时间:2014/5/14 21:02:44 点击: 2624 核心提示:今天为大家介绍下如何使用Origin9.1绘制如下图所示的风向 ...
- ffmpeg未整理好,有时间整理下
v 容器(Container) v 容器就是一种文件(封装)格式,比如flv.mkv.ts.mp4.rmvb.avi等.包含下面5种流以及文件头信息. v 流(Stream) v 是一种视频数 ...
- 解决KDE桌面环境下Eclipse崩溃的问题--让Eclipse使用特定的GTK2主题运行
最近在Kubuntu14.04上安装Eclipse,由于Ubuntu软件中心中的版本太老(3.8),而且会自动安装OpenJDK,于是到官网下载最新的4.4版.(Luna,代号很有亲切感有木有,女神万 ...
- poj 3264 Balanced Lineup (RMQ)
/******************************************************* 题目: Balanced Lineup(poj 3264) 链接: http://po ...