UIButton的用处特别多,这里只记录下把按钮应用在图文显示的场景,和需要把图片作为按钮的背景图片显示场景;

另外记录下在父控件的子控件优先显示方法(控件置于最前面和置于最后面)。

先上效果图:

1、当在某个地方既需要显示图片,还需要显示文字,另外还要有点击功能的时候,这时按钮是个很好的选择。

  按钮中的图片和文字的距离可以自由调整,图片的也可以上下左右翻转。日常项目中像这些场景都是很容易碰到的。

  按钮图文设置、图文位置移动、按钮中图片翻转示例代码:

/** 测试图文并茂的按钮,图文移动 */
- (void)addMoveImgAndTextButton{
//1、创建一个按钮:30x50
UIButton *iconBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[iconBtn setTitle:@"我的好友" forState:UIControlStateNormal];
[iconBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[iconBtn setImage:[UIImage imageNamed:@"pointer"] forState:UIControlStateNormal];
iconBtn.layer.borderColor = [UIColor redColor].CGColor; //边框颜色
iconBtn.layer.borderWidth = ; //边框宽度
iconBtn.titleLabel.backgroundColor = [UIColor greenColor]; //文字颜色
iconBtn.imageView.backgroundColor = [UIColor blackColor]; //图片颜色
[iconBtn addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:iconBtn];
self.iconBtn = iconBtn; //2、移动iconBtn按钮图片和文字
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[btn setTitle:@"图右移字左移" forState:UIControlStateNormal];
btn.titleLabel.numberOfLines = ;
[btn setBackgroundColor:[UIColor blackColor]];
[btn addTarget:self action:@selector(changeBtnFrame:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn]; //3、移动iconBtn按钮图片和文字
UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[btn2 setTitle:@"字右移图左移" forState:UIControlStateNormal];
btn2.titleLabel.numberOfLines = ;
[btn2 setBackgroundColor:[UIColor blackColor]];
[btn2 addTarget:self action:@selector(changeBtnFrame2:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn2]; //分割线
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
lineView.backgroundColor = [UIColor grayColor];
[self.view addSubview:lineView];
} /** 点击按钮使图片位置翻转 */
- (void)clickButton:(UIButton *)sender{
sender.imageView.transform = CGAffineTransformRotate(sender.imageView.transform, M_PI);
} /** 移动图片和文字位置 */
- (void)changeBtnFrame:(UIButton *)sender{ UIEdgeInsets edge = self.iconBtn.imageEdgeInsets;
CGFloat changeNum = ;
self.iconBtn.imageEdgeInsets = UIEdgeInsetsMake(, edge.left + changeNum, , -(edge.left + changeNum));
self.iconBtn.titleEdgeInsets = UIEdgeInsetsMake(, -(edge.left + changeNum), , edge.left + changeNum); NSLog(@"edge.left: %f, edge.right: %f", edge.left, edge.right);
} /** 反方向移动图片和文字位置 */
- (void)changeBtnFrame2:(UIButton *)sender{ UIEdgeInsets edge = self.iconBtn.imageEdgeInsets;
CGFloat changeNum = ;
self.iconBtn.imageEdgeInsets = UIEdgeInsetsMake(, edge.left - changeNum, , -(edge.left - changeNum));
self.iconBtn.titleEdgeInsets = UIEdgeInsetsMake(, -(edge.left - changeNum), , edge.left - changeNum); NSLog(@"...edge.left: %f, edge.right: %f", edge.left, edge.right);
}

2、有时候需要给按钮设置背景图片,一般UI给个图片,然后我们自己对图片进行处理,让背景图片自适应按钮展示,矩形圆角。

  但是有时候,产品要求显示的按钮左右必须是圆形的,这时候虽然可以让ui切个适配的图片做背景,其实针对如果是背景图片是纯色的话,我们可以利用

控件的layer.masksToBounds, 和layer.cornerRadius属性来让按钮或者其他控件左右两边都是圆形的。

下面写了五个橙色背景的按钮作比较:背景图片和按钮尺寸匹配的、背景图片和按钮尺寸或偏大或偏小的、处理背景图片让背景图片自适应按钮的、不用背景图片使用图层来设置按钮左右圆形的:

/** 测试给按钮设置背景图片 */
- (void)addBackgroundImgButton{
//4、96x25 按钮设置背景图片,颜色rgb(255,145,0)
UIImage *img = [UIImage imageNamed:@"btn_bg"];
UIButton *clickBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn setBackgroundImage:img forState:UIControlStateNormal];
[clickBtn setTitle:@"click Me" forState:UIControlStateNormal];
[self.view addSubview:clickBtn]; //4.2 给按钮设置背景图片, 按钮图片不适配
UIButton *clickBtn2 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn2 setBackgroundImage:img forState:UIControlStateNormal];
[clickBtn2 setTitle:@"click Me" forState:UIControlStateNormal];
[self.view addSubview:clickBtn2]; //4.3 给按钮设置背景图片,按钮和图片不适配
UIButton *clickBtn3 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn3 setBackgroundImage:img forState:UIControlStateNormal];
[clickBtn3 setTitle:@"click Me" forState:UIControlStateNormal];
[self.view addSubview:clickBtn3]; //4.4 处理背景图片,让背景图片自适应按钮
NSLog(@"img.size: %@", NSStringFromCGSize(img.size));
UIImage *newImg = [img stretchableImageWithLeftCapWidth:img.size.width/ topCapHeight:img.size.height/];
NSLog(@"newImg.size: %@", NSStringFromCGSize(newImg.size));
UIButton *clickBtn4 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn4 setBackgroundImage:newImg forState:UIControlStateNormal];
[clickBtn4 setTitle:@"click Me" forState:UIControlStateNormal];
[self.view addSubview:clickBtn4]; //4.5 按钮不使用背景图片,设置背景颜色当做有背景图片
UIButton *clickBtn5 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn5 setTitle:@"click Me" forState:UIControlStateNormal];
clickBtn5.layer.masksToBounds = YES;
clickBtn5.layer.cornerRadius = ;
clickBtn5.backgroundColor = [UIColor colorWithRed:/.f green:/.f blue: alpha:];
[self.view addSubview:clickBtn5]; //分割线
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
lineView.backgroundColor = [UIColor grayColor];
[self.view addSubview:lineView];
}

3、在有些场景下,需要控制控件的优先显示或者置后显示,需要用到方法

- (void)bringSubviewToFront:(UIView *)view;  // 将子控件view显示在父控件的所有子控件的最前面

- (void)sendSubviewToBack:(UIView *)view;  //将子控件view显示在父控件的所有子控件的最后面

示例代码:

/** 测试子控件的优先显示(置前和置后) */
- (void)testSubControlShowFront{
//1、红色view
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
redView.backgroundColor = [UIColor redColor];
redView.tag = ;
[self.view addSubview:redView]; //2、黑色view
UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
blackView.backgroundColor = [UIColor blackColor];
blackView.tag = ;
[self.view addSubview:blackView]; //3、紫色view
UIView *purpleView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
purpleView.backgroundColor = [UIColor purpleColor];
purpleView.tag = ;
[self.view addSubview:purpleView]; //添加操作按钮
UIButton *operatorBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[operatorBtn setTitle:@"红色置前" forState:UIControlStateNormal];
operatorBtn.tag = ;
operatorBtn.backgroundColor = [UIColor blackColor];
[operatorBtn addTarget:self action:@selector(changeViewToFrontShow:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:operatorBtn]; UIButton *operatorBtn2 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[operatorBtn2 setTitle:@"黑色置前" forState:UIControlStateNormal];
operatorBtn2.tag = ;
operatorBtn2.backgroundColor = [UIColor blackColor];
[operatorBtn2 addTarget:self action:@selector(changeViewToFrontShow:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:operatorBtn2]; UIButton *operatorBtn3 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[operatorBtn3 setTitle:@"紫色置前" forState:UIControlStateNormal];
operatorBtn3.tag = ;
operatorBtn3.backgroundColor = [UIColor blackColor];
[operatorBtn3 addTarget:self action:@selector(changeViewToFrontShow:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:operatorBtn3]; UIButton *operatorBtn4 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[operatorBtn4 setTitle:@"紫色置后" forState:UIControlStateNormal];
operatorBtn4.tag = ;
operatorBtn4.backgroundColor = [UIColor redColor];
[operatorBtn4 addTarget:self action:@selector(changeViewToFrontShow:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:operatorBtn4];
}
/** 操作按钮,切换view置前显示 */
- (void)changeViewToFrontShow:(UIButton *)sender{ if (sender.tag == ){
//红色置前
UIView *redView = [self.view viewWithTag:]; //将子控件redView在父控件view的所有子控件的最前面显示
[self.view bringSubviewToFront:redView];
}
else if (sender.tag == ){
//黑色置前
UIView *blackView = [self.view viewWithTag:]; //获取黑色子控件 //将子控件blackView在父控件view的所有子控件的最前面显示
[self.view bringSubviewToFront:blackView]; }
else if (sender.tag == ){
//紫色置前
UIView *purpleView = [self.view viewWithTag:]; //获取紫色子控件 //将子控件purpleView在父控件view的所有子控件的最前面显示
[self.view bringSubviewToFront:purpleView];
}
else if (sender.tag == ){
//紫色置后
UIView *purpleView = [self.view viewWithTag:]; //获取紫色子控件 //将子控件purpleView在父控件view的所有子控件的最后面显示
[self.view sendSubviewToBack:purpleView];
}
}

------------------------------------------------------------------------------

-----  完整代码  ------

//
// TestButtonVC.m
// tan_iosTwo
//
// Created by PX_Mac on 16/10/16.
//
// #import "TestButtonVC.h" @interface TestButtonVC () @property (nonatomic, weak) UIButton *iconBtn; //带文字和图片的按钮 @end @implementation TestButtonVC - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. [self addMoveImgAndTextButton]; //添加图文并茂的按钮,测试按钮上的图文移动 [self addBackgroundImgButton]; //添加设置背景图片的按钮 [self testSubControlShowFront]; //测试子控件的优先或置后显示
} /** 测试图文并茂的按钮,图文移动 */
- (void)addMoveImgAndTextButton{
//1、创建一个按钮:30x50
UIButton *iconBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[iconBtn setTitle:@"我的好友" forState:UIControlStateNormal];
[iconBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[iconBtn setImage:[UIImage imageNamed:@"pointer"] forState:UIControlStateNormal];
iconBtn.layer.borderColor = [UIColor redColor].CGColor; //边框颜色
iconBtn.layer.borderWidth = ; //边框宽度
iconBtn.titleLabel.backgroundColor = [UIColor greenColor]; //文字颜色
iconBtn.imageView.backgroundColor = [UIColor blackColor]; //图片颜色
[iconBtn addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:iconBtn];
self.iconBtn = iconBtn; //2、移动iconBtn按钮图片和文字
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[btn setTitle:@"图右移字左移" forState:UIControlStateNormal];
btn.titleLabel.numberOfLines = ;
[btn setBackgroundColor:[UIColor blackColor]];
[btn addTarget:self action:@selector(changeBtnFrame:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn]; //3、移动iconBtn按钮图片和文字
UIButton *btn2 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[btn2 setTitle:@"字右移图左移" forState:UIControlStateNormal];
btn2.titleLabel.numberOfLines = ;
[btn2 setBackgroundColor:[UIColor blackColor]];
[btn2 addTarget:self action:@selector(changeBtnFrame2:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn2]; //分割线
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
lineView.backgroundColor = [UIColor grayColor];
[self.view addSubview:lineView];
} /** 点击按钮使图片位置翻转 */
- (void)clickButton:(UIButton *)sender{
sender.imageView.transform = CGAffineTransformRotate(sender.imageView.transform, M_PI);
} /** 移动图片和文字位置 */
- (void)changeBtnFrame:(UIButton *)sender{ UIEdgeInsets edge = self.iconBtn.imageEdgeInsets;
CGFloat changeNum = ;
self.iconBtn.imageEdgeInsets = UIEdgeInsetsMake(, edge.left + changeNum, , -(edge.left + changeNum));
self.iconBtn.titleEdgeInsets = UIEdgeInsetsMake(, -(edge.left + changeNum), , edge.left + changeNum); NSLog(@"edge.left: %f, edge.right: %f", edge.left, edge.right);
} /** 反方向移动图片和文字位置 */
- (void)changeBtnFrame2:(UIButton *)sender{ UIEdgeInsets edge = self.iconBtn.imageEdgeInsets;
CGFloat changeNum = ;
self.iconBtn.imageEdgeInsets = UIEdgeInsetsMake(, edge.left - changeNum, , -(edge.left - changeNum));
self.iconBtn.titleEdgeInsets = UIEdgeInsetsMake(, -(edge.left - changeNum), , edge.left - changeNum); NSLog(@"...edge.left: %f, edge.right: %f", edge.left, edge.right);
} /** 测试给按钮设置背景图片 */
- (void)addBackgroundImgButton{
//4、96x25 按钮设置背景图片,颜色rgb(255,145,0)
UIImage *img = [UIImage imageNamed:@"btn_bg"];
UIButton *clickBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn setBackgroundImage:img forState:UIControlStateNormal];
[clickBtn setTitle:@"click Me" forState:UIControlStateNormal];
[self.view addSubview:clickBtn]; //4.2 给按钮设置背景图片, 按钮图片不适配
UIButton *clickBtn2 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn2 setBackgroundImage:img forState:UIControlStateNormal];
[clickBtn2 setTitle:@"click Me" forState:UIControlStateNormal];
[self.view addSubview:clickBtn2]; //4.3 给按钮设置背景图片,按钮和图片不适配
UIButton *clickBtn3 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn3 setBackgroundImage:img forState:UIControlStateNormal];
[clickBtn3 setTitle:@"click Me" forState:UIControlStateNormal];
[self.view addSubview:clickBtn3]; //4.4 处理背景图片,让背景图片自适应按钮
NSLog(@"img.size: %@", NSStringFromCGSize(img.size));
UIImage *newImg = [img stretchableImageWithLeftCapWidth:img.size.width/ topCapHeight:img.size.height/];
NSLog(@"newImg.size: %@", NSStringFromCGSize(newImg.size));
UIButton *clickBtn4 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn4 setBackgroundImage:newImg forState:UIControlStateNormal];
[clickBtn4 setTitle:@"click Me" forState:UIControlStateNormal];
[self.view addSubview:clickBtn4]; //4.5 按钮不使用背景图片,设置背景颜色当做有背景图片
UIButton *clickBtn5 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[clickBtn5 setTitle:@"click Me" forState:UIControlStateNormal];
clickBtn5.layer.masksToBounds = YES;
clickBtn5.layer.cornerRadius = ;
clickBtn5.backgroundColor = [UIColor colorWithRed:/.f green:/.f blue: alpha:];
[self.view addSubview:clickBtn5]; //分割线
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
lineView.backgroundColor = [UIColor grayColor];
[self.view addSubview:lineView];
} /** 测试子控件的优先显示(置前和置后) */
- (void)testSubControlShowFront{
//1、红色view
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
redView.backgroundColor = [UIColor redColor];
redView.tag = ;
[self.view addSubview:redView]; //2、黑色view
UIView *blackView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
blackView.backgroundColor = [UIColor blackColor];
blackView.tag = ;
[self.view addSubview:blackView]; //3、紫色view
UIView *purpleView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
purpleView.backgroundColor = [UIColor purpleColor];
purpleView.tag = ;
[self.view addSubview:purpleView]; //添加操作按钮
UIButton *operatorBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[operatorBtn setTitle:@"红色置前" forState:UIControlStateNormal];
operatorBtn.tag = ;
operatorBtn.backgroundColor = [UIColor blackColor];
[operatorBtn addTarget:self action:@selector(changeViewToFrontShow:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:operatorBtn]; UIButton *operatorBtn2 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[operatorBtn2 setTitle:@"黑色置前" forState:UIControlStateNormal];
operatorBtn2.tag = ;
operatorBtn2.backgroundColor = [UIColor blackColor];
[operatorBtn2 addTarget:self action:@selector(changeViewToFrontShow:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:operatorBtn2]; UIButton *operatorBtn3 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[operatorBtn3 setTitle:@"紫色置前" forState:UIControlStateNormal];
operatorBtn3.tag = ;
operatorBtn3.backgroundColor = [UIColor blackColor];
[operatorBtn3 addTarget:self action:@selector(changeViewToFrontShow:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:operatorBtn3]; UIButton *operatorBtn4 = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
[operatorBtn4 setTitle:@"紫色置后" forState:UIControlStateNormal];
operatorBtn4.tag = ;
operatorBtn4.backgroundColor = [UIColor redColor];
[operatorBtn4 addTarget:self action:@selector(changeViewToFrontShow:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:operatorBtn4];
}
/** 操作按钮,切换view置前显示 */
- (void)changeViewToFrontShow:(UIButton *)sender{ if (sender.tag == ){
//红色置前
UIView *redView = [self.view viewWithTag:]; //将子控件redView在父控件view的所有子控件的最前面显示
[self.view bringSubviewToFront:redView];
}
else if (sender.tag == ){
//黑色置前
UIView *blackView = [self.view viewWithTag:]; //获取黑色子控件 //将子控件blackView在父控件view的所有子控件的最前面显示
[self.view bringSubviewToFront:blackView]; }
else if (sender.tag == ){
//紫色置前
UIView *purpleView = [self.view viewWithTag:]; //获取紫色子控件 //将子控件purpleView在父控件view的所有子控件的最前面显示
[self.view bringSubviewToFront:purpleView];
}
else if (sender.tag == ){
//紫色置后
UIView *purpleView = [self.view viewWithTag:]; //获取紫色子控件 //将子控件purpleView在父控件view的所有子控件的最后面显示
[self.view sendSubviewToBack:purpleView];
}
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end

作者:xmTan

出处:http://www.cnblogs.com/tandaxia/

欢迎转载,但要在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。

欢迎指出博客中的错误。以免更多的人被误导。

记录下UIButton的图文妙用和子控件的优先显示的更多相关文章

  1. 记录下帮助一位网友解决的关于android子控件的onTouch或onClick和父OnTouch 冲突的问题。

    前三天收到位网友的私信求助,问题大概如标题所示.具体是下面的情况,个人感觉,这个问题挺有趣,也会在实际项目开发中很常见.不想看前奏的请直接跳至解决方法. 问题原型: 父控件是自定义的 LinearLa ...

  2. c# 遍历子控件,比如Form下的group,或者panel

    方法很好用.目的是遍历所有容器的子控件... 方法1private void GetControl(Control.ControlCollection ctc, ref int checkNull) ...

  3. 五种情况下会刷新控件状态(刷新所有子FWinControls的显示)——从DFM读取数据时、新增加子控件时、重新创建当前控件的句柄时、设置父控件时、显示状态被改变时

    五种情况下会刷新控件状态(刷新控件状态才能刷新所有子FWinControls的显示): 在TWinControls.PaintControls中,对所有FWinControls只是重绘了边框,而没有整 ...

  4. wpf 寻找某个控件下的子控件

    /// <summary> /// 寻找某个控件下的子控件 /// </summary> /// <typeparam name="ChildType" ...

  5. UIButton内部子控件自定义布局-“UIEdgeInsets”

    UIButton UIButton做frame动画时,不响应点击 在一个View内部加入几个按钮,然后改变这个view的frame来做动画,但是按钮不响应点击事件. 问题代码 __block CGRe ...

  6. QTP 自动化测试桌面程序--笔记(下拉选择、右键菜单、在控件仓库中查找对应的控件)

    0 在收集窗口控件信息时-最好将可输入的文字去掉,不然控件的名称按输入的文字标记 1 编辑时录制脚本-默认按当前显示的填入的数据标记控件 可以使用 tool-spy-查看控件的x,y 坐标,按坐标在学 ...

  7. 笔记03 wpf 在MVVM模式下怎样在Viewmodel里面获得view的控件对象

     转自http://blog.csdn.net/qing2005/article/details/6601199http://blog.csdn.net/qing2005/article/detail ...

  8. extjs4.0下的日期控件的星期显示为y的解决办法

    没有修改的时候的问题: 今天第一次写博客,就记录一下以前extjs4.2下运用日期组件的星期显示问题,当时找了n久,可能是extjs4.2才出来没多久,没有多少人发现这个问题或者说很少有人将Extjs ...

  9. CocoStudio UIButton setPressedActionEnabled(true) 子控件不跟着缩放

    具体情况是这样的:美术给了我 一个按钮的背景图片  一个按钮的文字图片,用背景图片创建一个button,然后把文字图片添加进去(注意关闭文字图片的交互功能) 设置UIButton setPressed ...

随机推荐

  1. Merge Sorted Array

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:Yo ...

  2. FreeBinary 格式说明

    说明 简称FB格式,是一个简单的二进制文件打包格式. 作用是FBX.unity.js等交换的一个中间格式. 由李剑英制定,易于读取,易于扩展 相应的代码可以用svn取得 SVN:http://code ...

  3. 一步一步使用ABP框架搭建正式项目系列教程之本地化详解

    返回总目录<一步一步使用ABP框架搭建正式项目系列教程> 本篇目录 扯扯本地化 ABP中的本地化 小结 扯扯本地化 本节来说说本地化,也有叫国际化.全球化的,不管怎么个叫法,反正道理都是一 ...

  4. 通过Gradle为APK瘦身

    引言:在过去几年中,APK 文件的大小曾急剧增长态势.一般来说,其原因如下:Android开发者获取了更多的依赖库,添加了更多的密度,Apps 增加了更多的功能.但实际上我们应该让APKs 尽可能的小 ...

  5. 牛逼的css3:动态过渡与图形变换

    写css3的属性的时候,最好加上浏览器内核标识,进行兼容. -ms-transform:scale(2,4); /* IE 9 */ -moz-transform:scale(2,4); /* Fir ...

  6. SQL Server-交叉联接、内部联接基础回顾(十二)

    前言 本节开始我们进入联接学习,关于连接这一块涉及的内容比较多,我们一步一步循序渐进学习,简短内容,深入的理解,Always to review the basics. 交叉联接(CROSS JOIN ...

  7. python3爬取1024图片

    这两年python特别火,火到博客园现在也是隔三差五的出现一些python的文章.各种开源软件.各种爬虫算法纷纷开路,作为互联网行业的IT狗自然看的我也是心痒痒,于是趁着这个雾霾横行的周末瞅了两眼,作 ...

  8. 读书笔记--SQL必知必会15--插入数据

    15.1 数据插入 使用INSERT语句将行插入(或添加)到数据库表.可能需要特定的安全权限. 插入完整的行 插入行的一部分 插入某些查询的结果 15.1.1 插入完整的行 要求指定表名和插入到新行中 ...

  9. 纯WebApi,不包含MVC Demo

    1.创建项目 只是单纯的使用Web API的功能,而不需要使用的MVC,这个时候就该抛开MVC来新建项目了. 首先,新建一个Asp.Net空应用程序,在程序集中添加引用System.Web.Http和 ...

  10. java设计模式之简单工厂模式

    简单工厂: 简单工厂的优点: 1.去除客户端与具体产品的耦合,在客户端与具体的产品中增加一个工厂类,增加客户端与工厂类的耦合 2.封装工厂类,实现代码平台的复用性,创建对象的过程被封装成工厂类,可以多 ...