方法一.

-(CGRect)imageRectForContentRect:(CGRect)contentRect {
    return CGRectMake(self.width - kImageW, 0, kImageW, self.height);
}
-(CGRect)titleRectForContentRect:(CGRect)contentRect {
    return CGRectMake(0, 0, self.width - kImageW, self.height);
}

方法二.

- (void)layoutSubviews {
    [super layoutSubviews];
    self.textLabel.frame = CGRectMake(0, 0, self.width, self.height);
}

iOS 设置button中图文位置的更多相关文章

  1. 通过代码设置button中文字的对齐方式

    // button.titleLabel.textAlignment = NSTextAlignmentLeft; 这句无效 button.contentHorizontalAlignment = U ...

  2. IOS设置button 图片 文字 上下、左右

    [btn setImage:imgNor forState:UIControlStateNormal]; [btn setImage:imgSel forState:UIControlStateSel ...

  3. iOS 设置Label中特定的文字大小和颜色

    直接上代码: _price = @"27"; NSMutableAttributedString *attributedString = [[NSMutableAttributed ...

  4. iOS 设置button文字过长而显示省略号的解决办法

    UIButton * button =[UIButton buttonWithType:UIButtonTypeCustom];button.titleLabel.adjustsFontSizeToF ...

  5. iOS设置UITableView中Cell被默认选中后怎么触发didselect事件

    //默认选中某个cell [self.searchResultTV selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] a ...

  6. iOS 设置文本中指定某段文本的颜色 大小

    NSString *money = @"300"; NSString *perStr = @"元/时"; NSString *text = [NSString  ...

  7. iOS 设置 文字和 图片的位置

    1.我最开始实现这个采用的方法:重新自定义一个view,然后有两个属性label和imageView,然后设置位置布局,再添加单击手势,用代理回传点击方法. 2.第二种方法:自定义一个Button继承 ...

  8. iOS中 图文混排/自定义图文混排 作者:韩俊强

    指示根视图:(准备几张图片,把label加载在window上) CustomLable *label = [[CustomLable alloc]initWithFrame:CGRectMake(0, ...

  9. Delphi for iOS开发指南(4):在iOS应用程序中使用不同风格的Button组件

    http://blog.csdn.net/DelphiTeacher/article/details/8923481 在FireMonkey iOS应用程序中的按钮 FireMoneky定义了不同类型 ...

随机推荐

  1. postgresql 热备与恢复

    一. PostgreSQL热备份的过程一般为: 数据库中执行:pg_start_backup() ; 然后使用操作系统的tar或 cp命令拷贝 PostgreSQL数据文件. 数据库中执行:pg_st ...

  2. [xcode]instruments来检验你的app

      原文网址:http://www.cocoachina.com/industry/20140114/7696.html     比较了好多关于instruments 还是发现老外写的比较牛逼.于是果 ...

  3. The Cow Lexicon

    The Cow Lexicon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8815 Accepted: 4162 Descr ...

  4. Ahui Writes Word

    Ahui Writes Word Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...

  5. H - Solve this interesting problem 分类: 比赛 2015-07-29 21:06 15人阅读 评论(0) 收藏

    Have you learned something about segment tree? If not, don't worry, I will explain it for you.  Segm ...

  6. Winsock系列函数 及 Socket通信流程

    Socket是一种网络通信机制   Winsock系列函数   1. Socket 创建socket   2. Connect 尝试连接远端Socket   3. Send 在某个Socket 向远端 ...

  7. Uva 1218 完美的服务

    题目链接:https://uva.onlinejudge.org/external/12/1218.pdf 题意: 一个网络,选出一些点做服务器,使满足一些条件,求服务器最少数量.条件是,每个计算机恰 ...

  8. 为什么需要main函数,及其参数的用法

    首先,需要明确main函数是什么? 答:main函数是C语言约定的入口函数 C99标准里面是这样描述的: Program startup The function called at program ...

  9. JAVA的名词释义

    JDK : Java Development Toolkit (java 开发工具包). JDK是整个JAVA的核心,包括了java运行环境(Java Runtime Envirnmet),一堆jav ...

  10. windows api线程

    一.1.定义入口函数static void  threadFunc(void);//在TestDlg.h里面声明 void CTestDlg::threadFunc(void) //在TestDlg. ...