假设有按钮rButton的 imageEdgeInsets和contentEdgeInsets可以设置按钮的标题和图片的位置,如下代码,设置标题居右

    NSString * rBtnTitle = @"删除";
CGSize size = [rBtnTitle sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:]}];
NSLog(@"size = %@",NSStringFromCGSize(size)); CGFloat leftPadding = CGRectGetWidth(rBtn.frame) - size.width;
rBtn.contentEdgeInsets = UIEdgeInsetsMake(, leftPadding, , );

代码设置UIButton文字、图片位置的更多相关文章

  1. iOS Button 上文字图片位置的设置

    1. 添加图片+文字/文字+图片 ,不分前后,图片默认在文字前边 加空格隔开 UIButton * button =[[UIButton alloc] initWithFrame:CGRectMake ...

  2. UIButton 文字图片排列

    UIButton缺省值是:图画-文字水平,所以我们并不需要调整. 1.写作-图画 水平显示,以前的文本,图片后再次 [btn setTitleEdgeInsets:UIEdgeInsetsMake(0 ...

  3. 设置UIButton文字大小颜色不同

    _loginBtn = [[UIButton alloc]initWithFrame:CGRectMake(iconX, CGRectGetMaxY(passwordBGView.frame)+25, ...

  4. QTbutton设置背景颜色和文字显示位置设置

    QPushButton * pQBtn = new QPushButton( cBuff, this ); pQBtn->setStyleSheet("text-align: left ...

  5. php生成文字图片效果

    php生成文字图片效果最近看到php的GD功能,试着做了一个基本生成文字图片效果的代码: 显示文字图片页面:demo.php<?php$str = $_REQUEST['str'] ? $_RE ...

  6. 改变UIButton 图片和文字的位置

    //设置字体和图片之间的间距 _btnLeft.titleEdgeInsets = UIEdgeInsetsMake(0, -_btnLeft.imageView.frame.size.width, ...

  7. iOS开发-- 设置UIButton的文字显示位置、字体的大小、字体的颜色

    btn.frame = CGRectMake(x, y, width, height); [btn setTitle: @"search" forState: UIControlS ...

  8. 设置UIButton的文字显示位置、字体的大小、字体的颜色

    btn.frame = CGRectMake(x, y, width, height); [btn setTitle: @"search" forState: UIControlS ...

  9. iOS UIButton文字和图片间距随意调整

    代码地址如下:http://www.demodashi.com/demo/11606.html 前记 在开发中,我们经常会遇到这么一种情况,就是一个按钮上面有图片也有文字,但是往往设计并不是我们想要的 ...

随机推荐

  1. 在floodlight源码的基础上添加一个新的module并正确运行

    1.在src/main/java目录下新建一个package,目录结构如下: 2.在新建的package下,新建一个class,名字就是自定义的module,接下来implements想实现的serv ...

  2. bottle框架学习(1):命令行

    在最初的一段代码,内容如下: if __name__ == '__main__': from optparse import OptionParser _cmd_parser = OptionPars ...

  3. CI中SESSION的用法及其注意

    销毁 Session要清除当前 session: $this->session->sess_destroy(); 注意: 此函数应该是最后被调用的.即使闪出变量已不再有效.如果你只想让某几 ...

  4. Spring:基于配置文件的创建对象的各种方式

    在Spring3.0之前,Spring主要创建对象的方法是基于配置文件的,即在配置文件中为对象进行注册,并且可以在配置文件当中为对象的字段或者称之为属性值进行赋值,接下来首先介绍基于配置文件的创建对象 ...

  5. Ubuntu角色登录答疑

    1.su 命令验证出错: $ su - rootPassword: su: Authentication failureSorry. 这时候输入 $ sudo passwd rootEnter new ...

  6. Codeforces Round #445 D. Restoration of string【字符串】

    D. Restoration of string time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  7. jQuery笔记:checkbox

    用jQuery操作checkbox时的一点小问题. 勾选checkbox的时候,$("#id").attr("checked")变为"checked& ...

  8. POJ1273 Drainage Ditches (网络流)

                                                             Drainage Ditches Time Limit: 1000MS   Memor ...

  9. sharepoint 2013 和 office web apps server 2013集成

    环境: 三台服务器  系统:window 2008 R2server01: 192.168.10.162(office web app)server02: 192.168.10.163(AD)serv ...

  10. db2字符串截取方法及常用函数

    select substr(index_code, 1, locate('-', index_code)-1) from report_data substr(str,m,n)表示从str中的m个字符 ...