// ----------------------------------UIButton------------------------------

// UIButtonTypeSystem 点击文字会有效果,变色  UIButtonTypeCustom 无点击效果

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

button.frame = CGRectMake(200, 100, 200, 80);

[button setTitle:@"click me" forState:UIControlStateNormal];

button.backgroundColor = [UIColor blueColor];

[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];

// 字体大小

button.titleLabel.font = [UIFont systemFontOfSize: 20.0];

//    button.font = [UIFont systemFontOfSize:20];  废弃

//边框

button.layer.borderWidth = 3;

button.layer.borderColor = [UIColor grayColor].CGColor;

// 设置圆角

[button.layer setMasksToBounds:YES];

[button.layer setCornerRadius:20.0];

// 按下会有发光的效果

button.showsTouchWhenHighlighted = YES;

// 文字居左

button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

// 文字居顶

button.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;

// 文字内边距

button.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 0, 0);

[button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];

UIButton详解的更多相关文章

  1. UI第二节——UIButton详解

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...

  2. UIButton 详解

    1)创建 UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 风格有如下 typedef enum { UIButt ...

  3. IOS开发学习笔记(2)-----UIButton 详解

    1. [代码][C/C++]代码     //这里创建一个圆角矩形的按钮    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRou ...

  4. 【iOS 开发】基本 UI 控件详解 (UIButton | UITextField | UITextView | UISwitch)

    博客地址 : http://blog.csdn.net/shulianghan/article/details/50051499 ; 一. UI 控件简介 1. UI 控件分类 UI 控件分类 : 活 ...

  5. 【iOS自定义键盘及键盘切换】详解

    [iOS自定义键盘]详解 实现效果展示: 一.实现的协议方法代码 #import <UIKit/UIKit.h> //创建自定义键盘协议 @protocol XFG_KeyBoardDel ...

  6. iOS中 HTTP/Socket/TCP/IP通信协议详解

    // OSI(开放式系统互联), 由ISO(国际化标准组织)制定 // 1. 应用层 // 2. 表示层 // 3. 会话层 // 4. 传输层 // 5. 网络层 // 6. 数据链接层 // 7. ...

  7. AFNetworking 与 UIKit+AFNetworking 详解

    资料来源 : http://github.ibireme.com/github/list/ios GitHub : 链接地址 简介 : A delightful iOS and OS X networ ...

  8. UI第六节——UINavigationController 详解

    1. UINavigationController 是一个容器类.里面盛放的是UIViewController. 容器的意思是,如果你不放入UIViewController,里面就是空的,什么也没有. ...

  9. UIWebView用法详解及代码分享

    今天我们来详细UIWebView用法.UIWebView是iOS内置的浏览器控件,可以浏览网页.打开文档等 能够加载html/htm.pdf.docx.txt等格式的文件. 用UIWebView我们就 ...

随机推荐

  1. 看StackOverflow如何用25台服务器撑起5.6亿的月PV

    问答社区网络 StackExchange 由 100 多个网站构成,其中包括了 Alexa 排名第 54 的 StackOverflow.StackExchang 有 400 万用户,每月 5.6 亿 ...

  2. laravel 外键schema RBAC

    $table->bigIncrements('id')  ;   Incrementing ID (primary key) using a " UNSIGNED BIG INTEGE ...

  3. Law of total probability

    https://en.wikipedia.org/wiki/Law_of_total_probability the total probability of an outcome which can ...

  4. js 定时跳转, 格式化字符串时间

    效果 1.js中将一字符串表示的系统时间转换为Date时间对象 //js中将一串字符串转换为date类型,主要是先过滤字符,然后分割开 function parseToDate(strTime) { ...

  5. 蓝牙Bluetooth技术手册规范下载

    [背景] 之前就已经整理和转帖了和蓝牙技术相关的一些内容: [资源下载]bluetooth 协议 spec specification 蓝牙1.1.蓝牙1.2.蓝牙2.0(蓝牙2.0+EDR)区别 但 ...

  6. 低功耗蓝牙4.0BLE编程-nrf51822开发(1)

    为了省钱,也为了提高手动能力,只买了块核心板,仿真器用的是旧的jinkv7,自己搭扩展板,DIY就这样开始了. 买这块之前做了些调查,最终选定了nrf51822,功耗低,性能强,开发难度小,虽然比TI ...

  7. MongoDB上的索引

    1. 将索引建在number键上名为nameIndex并且为正序索引({number:-1}为倒序索引) 如: db.list名.ensureIndex({number:1},{name:" ...

  8. 设计模式:迭代器模式(Iterator)

    定  义:提供一种方法顺序访问一个集合对象中的各个元素,而又不暴露该对象的内部元素. C#中实现,foreach 遍历

  9. 有关sass

    一.sass编译为css文件 编译的方法有很多 1.koala编译  请参考 http://www.w3cplus.com/blog/777.html http://koala-app.com/ind ...

  10. 简单的form表单

    效果 html <ul class="edit_list"> <li><em>*</em><span class=" ...