// ----------------------------------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. CodeIgniter 发送邮件

    1. 在config目录中增加email.php $config['charset'] = 'utf-8'; $config['wordwrap'] = TRUE; $config['protocol ...

  2. 【翻译】西川善司的「实验做出的游戏图形」「GUILTY GEAR Xrd -SIGN-」中实现的「纯卡通动画的实时3D图形」的秘密,后篇

    http://www.4gamer.net/games/216/G021678/20140714079/     连载第2回的本回,  Arc System Works开发的格斗游戏「GUILTY G ...

  3. Moving in Unity

    转自:http://angryant.com/2014/03/07/Moving-in-Unity/ ,详细描述了物体在unity中移动的几种方式,并且给出了代码描述,对加深对Unity理解很有帮助, ...

  4. Locking

    Computer Science An Overview _J. Glenn Brookshear _11th Edition To solve such problems, a DBMS could ...

  5. garbage collection - 垃圾收集

    Professional.JavaScript.for.Web.Developers.3rd.Edition.Jan.2012 JavaScript is a garbage-collected la ...

  6. Java多态性理解

      Java中多态性的实现 什么是多态 面向对象的三大特性:封装.继承.多态.从一定角度来看,封装和继承几乎都是为多态而准备的.这是我们最后一个概念,也是最重要的知识点. 多态的定义:指允许不同类的对 ...

  7. 捕获JS 错误日志

    最近在做项目的过程中,发现很多JS报错没有引起重视,我就想想把JS错误捕获了,然后展示在我们一个平台上 具体实现代码: window.onerror = function(message, url,  ...

  8. js 判断js函数、变量是否存在

    //是否存在指定函数 function isExitsFunction(funcName) { try { if (typeof(eval(funcName)) == "function&q ...

  9. Windows下git使用代理服务器的设置方法

    在我朝独有的无敌GFW关照下(当然,也有可能IP被网站封了),要下载网络上开源的软件是非常困难的一件事情,在这种情况下,使用VPN或者代理服务器就非常有必要了.对于单个应用FQ来说,个人比较喜欢用FQ ...

  10. 实验一补充内容 Java开发环境的熟悉-刘蔚然

    本次实验 PSP时间统计 步骤 耗时百分比 需求分析 5% 设计 10% 代码实现 67% 测试 15% 分析总结 3%