iOS_UIButton 简单操作
UIButton 风格
typedef NS_ENUM(NSInteger, UIButtonType) {
UIButtonTypeCustom = 0, // no button type
UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), // standard system button
UIButtonTypeDetailDisclosure,
UIButtonTypeInfoLight,
UIButtonTypeInfoDark,
UIButtonTypeContactAdd,
UIButtonTypeRoundedRect = UIButtonTypeSystem, // Deprecated, use UIButtonTypeSystem instead
};
简单操作
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
button.tag = 100; // 给 Button 加入标记 在不同的方法中使用同一个控件
button.frame = CGRectMake(30, 170, 200, 40);
[self.window addSubview:button];
// 设置按钮文字。须要设置状态
[button setTitle:@"按钮" forState:UIControlStateNormal];
// [button setTitle:@"Hello" forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; // 给字体设置颜色
button.showsTouchWhenHighlighted = YES; // 高亮
// 给button绑定事件
[button addTarget:self // 接受消息的对象
action:@selector(buttonAction:) // 发送的消息
forControlEvents:UIControlEventTouchUpInside]; // 触发的方式
Button 方法
- (void) buttonAction
{
NSLog(@"咔");
// 通过 tag 。从父类视图中获取button
UIButton *btn = (UIButton *)[self.window viewWithTag:100];
[btn setTitle:@"点我" forState:UIControlStateNormal];
// 让 Button 失效
[btn removeTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
}
- (void) buttonAction:(UIButton *)sender
{
sender.backgroundColor = [UIColor redColor];
}
iOS_UIButton 简单操作的更多相关文章
- x01.MagicCube: 简单操作
看最强大脑,发现魔方还是比较好玩的,便买了一个,对照七步还原法,居然也能成功还原. 为什么不写一个魔方程序呢?在网上找了找,略作修改,进行简单操作,还是不错的,其操作代码如下: protected o ...
- js简单操作Cookie
贴一段js简单操作Cookie的代码: //获取指定名称的cookie的值 function getCookie(objName) { var arrStr = document.cookie.spl ...
- GitHub学习心得之 简单操作
作者:枫雪庭 出处:http://www.cnblogs.com/FengXueTing-px/ 欢迎转载 前言 本文对Github的基本操作进行了总结, 主要基于以下文章: http://gitre ...
- Linq对XML的简单操作
前两章介绍了关于Linq创建.解析SOAP格式的XML,在实际运用中,可能会对xml进行一些其它的操作,比如基础的增删该查,而操作对象首先需要获取对象,针对于DOM操作来说,Linq确实方便了不少,如 ...
- Linux 中 Vi 编辑器的简单操作
Linux 中 Vi 编辑器的简单操作 Vi 编辑器一共有3种模式:命名模式(默认),尾行模式,编辑模式.3种模式彼此需要切换. 一.进入 Vi 编辑器的的命令 vi filename //打开或新 ...
- python(pymysql)之mysql简单操作
一.mysql简单介绍 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库 ...
- ZooKeeper系列3:ZooKeeper命令、命令行工具及简单操作
问题导读1.ZooKeeper包含哪些常用命令?2.通过什么命令可以列出服务器 watch 的详细信息?3.ZooKeeper包含哪些操作?4.ZooKeeper如何创建zookeeper? 常用命令 ...
- ORACLE的安装与网页版创建表空间的简单操作以及PLsql的简单操作
1.oracle的安装: 安装简单易学,在这里不做解释.下载看装包后耐心等待,注意安装目录不要有中文字符,尽量按照指定目录进行安装.安装完成后会占用有大约5g的内存. 如果要卸载oracle,需要用其 ...
- C#反射技术的简单操作(读取和设置类的属性)
public class A { public int Property1 { get; set; } } static void Main(){ A aa = new A(); Type type ...
随机推荐
- javascript 变量转义
$(this).append('<a href="2-1partner.html"><div><img width="645" h ...
- Sencha app build 出现 missing name after . operator 问题
此问题是在使用sencha app build命令后出现得 主要是 YUI Compressor压缩的时候,代码中出现了delete, interface之类的keyword导致的. 此时能够在Web ...
- .atitit.web 推送实现解决方式集合(3)----dwr3 Reverse Ajax
.atitit.web 推送实现解决方式集合(3)----dwr3 Reverse Ajax 1. 原理实现 1 2. Page 添加配置.添加回调函数dwr.engine.setActiveRev ...
- 挑战一下吧!C#测试开发工程师英语面试题
1. Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size o ...
- EasyUI - Resizable 调整大小
效果: html代码: <div id="rr" style="width: 100px; height: 100px; border: 2px solid #cc ...
- 键盘皇者 RealForce 104Pro独家评测
http://tech.sina.cn/?sa=t84d20738943v44&page=2&pwt=rest2&vt=4&from=mbaidu&clickt ...
- Android:自定义滚动边缘(EdgeEffect)效果
Android可滚动控件(GridView.ListView.ScrollView等)当用户滚动到头的时候会有个边缘反馈效果,在4.0上默认为Holo蓝色效果. 如果您的App自定义了主题颜色,比如 ...
- android面试题2
一.属于GLSurFaceView特性的是: 1.管理一个surface,这个surface就是一块特俗的内存.能直接排版到Android的视图view上. 2.管理一个EGL display,它能让 ...
- Excel设置下拉选项的方法
前些日子参加提高班组织的数据采集工作,到各个二级学院搜集数据,当然离不开我们常用的Excel表格了.在这次采集数据的过程过程中还真学到了一两招.就比如在Excel中设置下拉选项的方法. 例如我们要在A ...
- UVA 10795 - A Different Task(递归)
A Different Task The (Three peg) Tower of Hanoi problem is a popular one in computer science. Brie ...