UIButtonType各个类型的解释:
UIButtonType各个类型的解释:
typedef NS_ENUM(NSInteger, UIButtonType) {
UIButtonTypeCustom = ,
UIButtonTypeSystem,
UIButtonTypeDetailDisclosure,
UIButtonTypeInfoLight,
UIButtonTypeInfoDark,
UIButtonTypeContactAdd,
UIButtonTypePlain,
UIButtonTypeRoundedRect = UIButtonTypeSystem
};
UIButtonTypeCustom:
官方:No button style.
解释:自定义的按钮(无样式)UIButtonTypeSystem:
官方:A system style button, such as those shown in navigation bars and toolbars.
解释:系统样式UIButtonTypeDetailDisclosure:
官方:A detail disclosure button.
解释:细节详情样式UIButtonTypeInfoLight:
官方:An information button that has a light background.
解释:按钮图片为i字母(info)亮的信息类型UIButtonTypeInfoDark:
官方:An information button that has a dark background.
解释:按钮图片为i字母(info)暗的信息类型
注意: iOS7及之后,只有在设置showsTouchWhenHighlighted为YES的时候,DetailDisclosure的外观和InfoLight/InfoDark不同(测试的时候我并没有看出来什么不同,如果你看出来了,劳烦告诉我),其他情况下都相同
UIButtonTypeContactAdd:
官方:A contact add button.
解释:加号(➕)按钮类型UIButtonTypePlain:
官方:A standard system button without a blurred background view.
解释:没有模糊背景视图的标准的系统按钮 不过只支持 tvOSUIButtonTypeRoundedRect = UIButtonTypeSystem:
官方:A rounded-rectangle style button.
解释:方形的圆角形式的按钮,在iOS7后被废弃,现在需要使用border的方式来做到效果
注意:(UIButtonTypeRoundedRect已废弃, UIButtonTypeRoundedRect的枚举值为1 !
相关代码
#import "QiButton_ButtonTypeViewController.h" @interface QiButton_ButtonTypeViewController ()
@end @implementation QiButton_ButtonTypeViewController - (void)viewDidLoad {
[super viewDidLoad];
self.title = @"UIButtonType";
[self buttonType];
} #pragma mark - Private functions
- (void)buttonType {
NSArray <NSString *>*buttonTypes = @[@"UIButtonTypeCustom",
@"UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0)",
@"UIButtonTypeDetailDisclosure",
@"UIButtonTypeInfoLight",
@"UIButtonTypeInfoDark",
@"UIButtonTypeContactAdd",
@"UIButtonTypePlain API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios, watchos)",
@"7 = UIButtonTypePlain | UIButtonTypeSystem",
@"UIButtonTypeRoundedRect = UIButtonTypeSystem",
@"new a Button"];
CGFloat btnHeight = [UIScreen mainScreen].bounds.size.height / buttonTypes.count; for (NSInteger buttonTypeI = ; buttonTypeI < buttonTypes.count; buttonTypeI ++) {
UIButton *buttonTypeBtn = [UIButton buttonWithType:buttonTypeI];
// 设置最后的一个按钮 new的方式创建
if (buttonTypeI == buttonTypes.count - ) {
// 经测试 打印的btn.buttonType 为 UIButtonTypeCustom 观察button的显示样式也是如此
buttonTypeBtn = [UIButton new];
[buttonTypeBtn setImage:[UIImage imageNamed:@"smallQiShareLogo"] forState:UIControlStateNormal];
[buttonTypeBtn setImage:[UIImage imageNamed:@"smallQiShareLogo"] forState:UIControlStateHighlighted];
} else if(buttonTypeI == buttonTypes.count - ) {
/** 注意UIButtonTypeRoundedRect = UIButtonTypeSystem 真正的值为 1 而不是7
如果以 [UIButton buttonWithType:7] 方式创建UIButton
相当于 [UIButton buttonWithType:UIButtonTypePlain | UIButtonTypeSystem];
*/
buttonTypeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[buttonTypeBtn setImage:[UIImage imageNamed:@"smallQiShareLogo"] forState:UIControlStateNormal];
[buttonTypeBtn setImage:[UIImage imageNamed:@"smallQiShareLogo"] forState:UIControlStateHighlighted];
} else if(buttonTypeI == UIButtonTypeCustom || buttonTypeI == UIButtonTypeSystem || buttonTypeI == UIButtonTypeRoundedRect) {
[buttonTypeBtn setImage:[UIImage imageNamed:@"smallQiShareLogo"] forState:UIControlStateNormal];
[buttonTypeBtn setImage:[UIImage imageNamed:@"smallQiShareLogo"] forState:UIControlStateHighlighted];
} else if(buttonTypeI == UIButtonTypeDetailDisclosure || buttonTypeI == UIButtonTypeInfoLight || buttonTypeI == UIButtonTypeInfoDark) {
buttonTypeBtn.showsTouchWhenHighlighted = YES;
}
[self.view addSubview:buttonTypeBtn];
buttonTypeBtn.frame = CGRectMake(., buttonTypeI * btnHeight, CGRectGetWidth(self.view.frame), btnHeight);
buttonTypeBtn.backgroundColor = (buttonTypeI % ? [UIColor lightGrayColor] : [UIColor colorWithWhite:0.8 alpha:0.8]);
[buttonTypeBtn setTitle:buttonTypes[buttonTypeI] forState:UIControlStateNormal];
buttonTypeBtn.titleLabel.numberOfLines = ; [buttonTypeBtn addTarget:self action:@selector(buttonTypeButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
} #pragma mark - Action functions - (void)buttonTypeButtonClicked:(UIButton *)sender {
sender.selected = !sender.selected;
} @end
UIButtonType各个类型的解释:的更多相关文章
- Java中JNI的使用详解第二篇:JNIEnv类型和jobject类型的解释
上一篇说的是一个简单的应用,说明JNI是怎么工作的,这一篇主要来说一下,那个本地方法sayHello的参数的说明,以及其中方法的使用 首先来看一下C++中的sayHello方法的实现: JNIEXPO ...
- (转+原创)java的枚举类型Enum解释
原文:http://www.cnblogs.com/mxmbk/articles/5091999.html 下文中还添加了个人的一些补充和理解. 在Java SE5之前,我们要使用枚举类型时,通常会使 ...
- string类型的解释与方法
基本概念 string(严格来说应该是System.String) 类型是我们日常coding中用的最多的类型之一.那什么是String呢?^ ~ ^ String是一个不可变的连续16位的Unico ...
- OS UIButton之UIButtonType详解-转
我做了一个关于UIButtonType的Demo,效果如下图: UIButtonType各个类型的解释: typedef NS_ENUM(NSInteger, UIButtonType) { UIBu ...
- PHP弱类型需要特别注意的问题
下面介绍的问题都已验证, 总结:字符数据比较==不比较类型,会将字符转数据,字符转数字(转换直到遇到一个非数字的字符.即使出现无法转换的字符串,intval()不会报错而是返回0).0e,0x开头的字 ...
- PHP弱类型安全问题的写法和步骤
鉴于目前PHP是世界上最好的语言,PHP本身的问题也可以算作是web安全的一个方面.在PHP中的特性就是弱类型,以及内置函数对于传入参数的松散处理.本篇文章主要就是记录我在做攻防平台上面遇到的PHP的 ...
- 详解MySQL中EXPLAIN解释命令(转)
explain显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. 使用方法,在select语句前加上explain就可以了: 如: expla ...
- MySQL中EXPLAIN解释命令详解
MySQL中的explain命令显示了mysql如何使用索引来处理select语句以及连接表.explain显示的信息可以帮助选择更好的索引和写出更优化的查询语句. 1.EXPLAIN的使用方法:在s ...
- C++类型转化:static_cast,reinterpret_cast,dynamic_cast,const_cast
类型转换名称和语法 C风格的强制类型转换(Type Cast)很简单,不管什么类型的转换统统是: TYPE b = (TYPE)a C++风格的类型转换提供了4种类型转换操作符来应对不同场合的应用. ...
随机推荐
- JavaScript 数组对象常用属性
concat() 用于连接两个或多个数组.该方法不会改变现有的数组,而仅仅会返回被连接数组的一个副本. var a = ["aa","ccc"]; var b ...
- Java 监听器,国际化
1. 监听器 1.1 概述 监听器: 主要是用来监听特定对象的创建或销毁.属性的变化的! 是一个实现特定接口的普通java类! 对象: 自己创建自己用 (不用监听) 别人创建自己用 (需要监听) Se ...
- 通过JTS源码分析Rtree(未完待续)
前言 R树在数据库等领域做出的功绩是非常显著的.它很好的解决了在高维空间搜索等问题.它把B树的思想很好的扩展到了多维空间,采用了B树分割空间的思想,并在添加.删除操作时采用合并.分解结点的方法,保证树 ...
- C# ——窗体和控件随着分辨率的变化自适应大小
一.说明 我们自己编写程序的界面,会遇到各种屏幕分辨 率,只有自适应才能显的美观.实际上,做到这点也很简单,就是首先记录窗体和它上面控件的初始位置和大小,当窗体改变比例时,其控件的位置和大小也按此比 ...
- TextView的跑马灯效果(AS开发实战第二章学习笔记)
TextView的跑马灯效果跑马灯用到的属性与方法说明singleLine 指定文本是否单行显示ellipsize 指定文本超出范围后的省略方式focusable 指定是否获得焦点,跑马灯效果要求设置 ...
- cocos2d在CCScrollView中嵌套CCMenu列表
在cocos2d中,CCMenuItem经常被当做按钮使用.在有许多条目需要逐行显示,并且点击每个条目都触发对应的事件的需求下,最容易想到的是用CCScrollView嵌套CCMenu. 但默认情况下 ...
- 【Leetcode】【Medium】3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...
- 网页入口ControlServlet分析
init() configureBsf(); //配置自定义bsf,即在bean script中注册ofbiz实现的脚本引擎 getRequestHandler(); //初始化request han ...
- TIAGO机器人传感器参数简介 手册翻译
本来认为这篇文章是最没人气的,竟然收到了回复,看来要继续更新本文了.留下笔者联系方式,邮箱leop22@163.com,欢迎邮件交流. 防止不良爬虫,原文链接:http://www.cnblogs.c ...
- 一个较复杂的执行redis的lue脚本
