//1.添加按钮
UIButton *nameView=[UIButton buttonWithType:UIButtonTypeCustom];
//nameView.backgroundColor=[UIColor redColor];
[nameView setBackgroundImage:[UIImage imageNamed:@"buddy_header_bg"] forState:UIControlStateNormal]; [nameView setBackgroundImage:[UIImage imageNamed:@"buddy_header_bg_highlighted"] forState:UIControlStateHighlighted]; //设置按钮内部的左边箭头图片
[nameView setImage:[UIImage imageNamed:@"buddy_header_arrow"] forState:UIControlStateNormal];
[nameView setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; // //设置按钮的内容左对齐
// nameView.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
// 设置按钮的内容左对齐
nameView.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; //设置按钮的内边距
nameView.titleEdgeInsets=UIEdgeInsetsMake(, , , );
nameView.contentEdgeInsets=UIEdgeInsetsMake(, , , );
[nameView addTarget:self action:@selector(nameViewClick) forControlEvents:UIControlEventTouchUpInside]; //设置按钮内部的imageView的内容模型为居中
nameView.imageView.contentMode=UIViewContentModeCenter; //超出边框的内容不需要裁剪
nameView.imageView.clipsToBounds=NO; [self.contentView addSubview:nameView];
self.nameView=nameView;

IOS UIButton常用属性的更多相关文章

  1. UIButton常用属性小结(编辑中。。。)

    Button的功能很黄很暴力,即能显示文字,又能显示图片,还能随时调整内部图片和文字的位置,用的地方很多. (1)按钮常用的四种状态: normal(普通状态) 默认情况(Default) 对应的枚举 ...

  2. iOS:常用属性、方法

    前言:一段时间没接触,很容易就忘记以前的知识.专写一篇,供几个月没接触,拿起却忘记了. 0.宏定义.系统相关 0-1).宏定义.规范 变量: //全局变量通常用小写g来提示 int gNumb=0; ...

  3. 【iOS】UIButton 常用属性

    发现 UIButton 的相关属性不熟悉了……常用的一些属性代码如下: UIButton *add = [UIButton buttonWithType:UIButtonTypeCustom]; ad ...

  4. iOS中常用属性的关键字的使用说明

    属性关键字的作用 现在我们iOS开发中,基本都是使用ARC(自动引用计数)技术,来编写我们的代码.因此在属性property中我们经常使用的关键字有strong,weak,assign,copy,no ...

  5. ios cell常用属性

    1.设置UITableViewCell的accessoryView 有时候我们需要设置cell的一些样式,比如下图, 这个就是设置了cell的accessory属性的内容,如果我们想在上面显示Swit ...

  6. 给iOS开发新手送点福利,简述UIButton的属性和用法

    UIButton属性 1.UIButton状态: UIControlStateNormal          // 正常状态    UIControlStateHighlighted     // 高 ...

  7. ios 按钮常见属性

    1.UIButton状态: UIControlStateNormal          // 正常状态    UIControlStateHighlighted     // 高亮状态    UICo ...

  8. iOS UIView控件的常用属性和方法的总结

    一 UIVIew 常见属性1.frame 位置和尺寸(以父控件的左上角为原点(0,0))2.center 中点 (以父控件的左上角为原点(0,0))3.bounds 位置和尺寸(以自己的左上角为原点 ...

  9. UIButton的常用属性

    可以通过代码的方式创建UIButton 通用实例化对象方法: UIButton *button = [[UIButton alloc] initWithFrame:rect]; 快速实例化对象方法: ...

随机推荐

  1. Yum本地源制作

    参考文档 环境准备 # cat /etc/os-release NAME="CentOS Linux" VERSION="7 (Core)" ID=" ...

  2. 微信小程序小结(1) ------ 前后端交互及wx.request的简易封装

    微信小程序的应用目前越来越多,不管喜欢与否我们都应该了解一些.废话不多,直接干货. 做项目自然避免不了前后端的交互,小程序在调试过程中需要在先在:小程序公众平台--设置--开发设置中,将要从后台请求的 ...

  3. 796D(bfs)

    题目链接: http://codeforces.com/problemset/problem/796/D 题意: 给出一颗 n 个节点树, 树枝连接的两个定点距离为 1, 树中有 k 个特殊点, 问最 ...

  4. 快速搭建angular7 前端开发环境

    第一步:全局安装 Angular CLI (1)打开npm(终端)安装angular-cli 第二步:创造工作区和初始应用 (1)运行命令 ng new my-app 第三步:启动开发服务器 (1)c ...

  5. ldap第二天-yum安装LDAP + phpLDAPadmin

    1.安装LDAP服务器和客户端,migrationtools工具包 yum install -y openldap-servers openldap-clients migrationtools 2. ...

  6. Observer模式(观察者设计模式)

    Observer 设计模式? 在Observer模式中,当观察对象的状态发生变化时,会通知给观察者.Observer模式适用于根据对象状态进行相应处理的场景. Observer 并非主动观察,而是被动 ...

  7. PHPExcel探索之旅---阶段二 设置表格样式

    1.设置表格的默认样式为水平居中.垂直居中 getDefaultStyle()函数用来设置默认样式 由活动sheet对象来调用,setVertical()函数和setHorizontal()函数分别用 ...

  8. A^B mod (大数运算)

    #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; ; cha ...

  9. 华东交通大学2017年ACM“双基”程序设计竞赛 1008

    Problem Description 长度为 n 的序列,把它划分成两段非空的子序列,定义权值为:两段子序列的最大值的差的绝对值.求可能的最大的权值.数据范围:2 <= n <= 10^ ...

  10. ERROR: Unable to globalize '/usr/local/NONE/etc/php-fpm.d/*.conf' (ret = 2) from /usr/local/etc/php-fpm.conf at line WARNING: Nothing matches the include pattern '/usr/local/php7/etc/php-fpm.d/*.conf'

    Building from source is not easy if something is a bit different, and I had a hard time with some di ...