// ----------------------------------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. github 有名的问题【ERROR: Permission to .git denied to user】

    小乌龙 以前一直是单兵做战,所以github repo对于我而言,只是一个存放.同步.备份代码的地方,协同作用完全没有体现出来. 最近跟朋友一起开发一个项目,他在github建了个公共的repo,我正 ...

  2. android文字阴影效果(转)

    关于android文字阴影,共有四个属性可以设置: android:shadowColor :阴影颜色 android:shadowDx :阴影x方向位移 android:shadowDy :阴影y方 ...

  3. 【转】NGUI创建UIRoot后报NullReferenceException的解决办法

    本文参考自 http://forum.china.unity3d.com/thread-1099-1-1.html 使用NGUI版本3.7.5. 在创建了一个UIRoot后,有时会报NullRefer ...

  4. 一个Delphi7的BUG

    combobox有个属性DropDownCount可以控制显示的下拉数量, 但是 在Delphi7中, TCombobox或者任何从TCustomComboBox继承下来的类, 在windows7环境 ...

  5. redis配置文件中文解释

    # redis 配置文件示例 # 当你需要为某个配置项指定内存大小的时候,必须要带上单位, # 通常的格式就是 1k 5gb 4m 等酱紫: # # 1k => bytes # 1kb => ...

  6. html5学习测试

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. Asp.Net MVC 路由

    原文链接:http://www.asp.net/learn/mvc/ 在这篇教程中,我将为你介绍每个ASP.NET MVC应用程序都具有的一个重要功能,称作ASP.NET路由(ASP.NET Rout ...

  8. Estimating Project Costs

    The Wideman Comparative Glossary of Common Project Management Terms describes estimating cost as, &q ...

  9. 解决在VMware中安装64位系统时“此主机具有虚拟化支持能力的,但虚拟化技术被禁用”的方法

    您已经配置此虚拟机使用64位客户操作系统.然而,64位操作系统不可用.此主机具有虚拟化支持能力的,但虚拟化技术被禁用.这通常是因为虚拟化技术已经在BIOS /固件设置或禁用或主机没有权限改变此设置. ...

  10. C#获取管理员权限

    在进行C盘的读写时,有时会需要用到管理员权限 //找到位于 Properties 下面的 app.manifest 文件 将<requestedExecutionLevel level=&quo ...