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.
    解释:没有模糊背景视图的标准的系统按钮 不过只支持 tvOS

  • UIButtonTypeRoundedRect = 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各个类型的解释:的更多相关文章

  1. Java中JNI的使用详解第二篇:JNIEnv类型和jobject类型的解释

    上一篇说的是一个简单的应用,说明JNI是怎么工作的,这一篇主要来说一下,那个本地方法sayHello的参数的说明,以及其中方法的使用 首先来看一下C++中的sayHello方法的实现: JNIEXPO ...

  2. (转+原创)java的枚举类型Enum解释

    原文:http://www.cnblogs.com/mxmbk/articles/5091999.html 下文中还添加了个人的一些补充和理解. 在Java SE5之前,我们要使用枚举类型时,通常会使 ...

  3. string类型的解释与方法

    基本概念 string(严格来说应该是System.String) 类型是我们日常coding中用的最多的类型之一.那什么是String呢?^ ~ ^ String是一个不可变的连续16位的Unico ...

  4. OS UIButton之UIButtonType详解-转

    我做了一个关于UIButtonType的Demo,效果如下图: UIButtonType各个类型的解释: typedef NS_ENUM(NSInteger, UIButtonType) { UIBu ...

  5. PHP弱类型需要特别注意的问题

    下面介绍的问题都已验证, 总结:字符数据比较==不比较类型,会将字符转数据,字符转数字(转换直到遇到一个非数字的字符.即使出现无法转换的字符串,intval()不会报错而是返回0).0e,0x开头的字 ...

  6. PHP弱类型安全问题的写法和步骤

    鉴于目前PHP是世界上最好的语言,PHP本身的问题也可以算作是web安全的一个方面.在PHP中的特性就是弱类型,以及内置函数对于传入参数的松散处理.本篇文章主要就是记录我在做攻防平台上面遇到的PHP的 ...

  7. 详解MySQL中EXPLAIN解释命令(转)

    explain显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. 使用方法,在select语句前加上explain就可以了: 如: expla ...

  8. MySQL中EXPLAIN解释命令详解

    MySQL中的explain命令显示了mysql如何使用索引来处理select语句以及连接表.explain显示的信息可以帮助选择更好的索引和写出更优化的查询语句. 1.EXPLAIN的使用方法:在s ...

  9. C++类型转化:static_cast,reinterpret_cast,dynamic_cast,const_cast

    类型转换名称和语法 C风格的强制类型转换(Type Cast)很简单,不管什么类型的转换统统是: TYPE b = (TYPE)a C++风格的类型转换提供了4种类型转换操作符来应对不同场合的应用. ...

随机推荐

  1. JS对象原型的理解

    基于原型的语言 JavaScript 常被描述为一种基于原型的语言 (prototype-based language)——每个对象拥有一个原型对象,对象以其原型为模板.从原型继承方法和属性.原型对象 ...

  2. .NET开源工作流RoadFlow-Bug修改-1.8.2表单验证时ueditor编辑非空验证无效

    RoadFlow生成的表单,Ueditor编辑器不能进行非空验证的BUG修改: 1.修改控制器:WorkFlowFormDesignerController红框处: 2.修改js文件:Scripts/ ...

  3. android网络监听

    http://blog.csdn.net/mxiaoyem/article/details/50857008 http://blog.csdn.net/ke1vin/article/details/5 ...

  4. pt-deadlock-logger使用

    死锁监控pt-deadlock-logger 首先我们要创建一个表用来保存死锁的信息: CREATE TABLE deadlocks ( server ) NOT NULL, ts timestamp ...

  5. 30分钟学会JS AST,打造自己的编译器

    这是一棵树嘛 直奔主题 抽象语法树是js代码另一种结构映射,可以将js拆解成AST,也可以把AST转成源代码.这中间的过程就是我们的用武之地. 利用 抽象语法树(AST) 可以对你的源代码进行修改.优 ...

  6. less 学习

    收藏地址 : http://www.bootcss.com/p/lesscss/

  7. 一个较复杂的执行redis的lue脚本

  8. June 25th 2017 Week 26th Sunday

    There is always that one song that brings back old memories. 总有那么一首歌,让你想起那些旧的回忆. There are seveal so ...

  9. C#图解教程读书笔记(第2章 C#编程概述)

    这章主要是一个对于C#程序的概括解释 和C/C++不同,不是用include声明引用的头文件,而是通过using的方式,声明引用的命名空间. 命名和C/C++类似,并且也是区分大小写的,这件事情在VB ...

  10. 编码 Unicode utf-8

    编码的发展史: 一开始计算机只在美国使用.8位的字节可以组合出256种不同的状态.他们将0到32种状态规定为”控制码“,后来又用其中32号以后的状态表示空格.标点符号.数字和大小写字母.这样一直编到了 ...