zoukankan      html  css  js  c++  java
  • contentHorizontalAlignment 属性浅析

    转载自:http://blog.csdn.net/s0228g0228/article/details/46832285

    最近在iOS 7以上总是碰到导航条上左右按钮距离边距太大的问题

    为了解决这个这个问题 特别使用了setImageEdgeInsets 和 

    使用中碰到的范二的事情总结下:警示他人

    1.setImageEdgeInsets针对的是UIbutton的setImage方法。如果使用setbackimage方法。则会失效无用。

     2.btn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft ;//设置文字位置,现设为居左,默认的是居中

    [btn setTitle:@“title”forState:UIControlStateNormal];// 添加文字

    有些时候我们想让UIButton的title居左对齐,我们设置

    btn.textLabel.textAlignment = UITextAlignmentLeft

    是没有作用的,我们需要设置

    btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;

    但是问题又出来,此时文字会紧贴到做边框,我们可以设置

    btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);

    使文字距离做边框保持10个像素的距离。

    =======================================================

    设置UIButton上字体的颜色设置UIButton上字体的颜色,不是用:

    [btn.titleLabel setTextColor:[UIColorblackColor]];

    btn.titleLabel.textColor=[UIColor redColor];

    而是用:

    [btn setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];

  • 相关阅读:
    5.8
    python运维自动化
    javascript学习(一)
    python学习-1
    A-GPS学习笔记(二) 之SUPL
    A-GPS学习笔记(一)
    CF756D Bacterial Melee
    LG P2495 [SDOI2011]消耗战
    LG P7325 [WC2021] 斐波那契
    LG P7324 [WC2021] 表达式求值
  • 原文地址:https://www.cnblogs.com/Jenaral/p/5533573.html
Copyright © 2011-2022 走看看