各种内容对齐 总结

********************** 一 //textAlignment:文字的 水平方向 对齐 ***********************

    NSTextAlignmentLeft    左对齐      

    NSTextAlignmentCenter  居中  

    NSTextAlignmentRight   右对齐 

 

能显示文字的控件一般都有这个属性,

如:label.textAlignment//

 textField.textAlignment //

 textView.textAlignment//

 

********************* 二 //内容的对齐 ***************

(1) contentVerticalAlignment:内容的 垂直方向 对齐

typedef NS_ENUM(NSInteger, UIControlContentVerticalAlignment) {

    //竖直方向 居中对齐

    UIControlContentVerticalAlignmentCenter  = 0,

    //顶部对齐

    UIControlContentVerticalAlignmentTop     = 1,

    //底部对齐

    UIControlContentVerticalAlignmentBottom  = 2,

    //

    UIControlContentVerticalAlignmentFill    = 3,

 

};

 

(2) contentHorizontalAlignment:内容的 水平方向 对齐

typedef NS_ENUM(NSInteger, UIControlContentHorizontalAlignment) {

    //水平方向 居中对齐

    UIControlContentHorizontalAlignmentCenter = 0,

    //左对齐

    UIControlContentHorizontalAlignmentLeft   = 1,

    //右对齐

    UIControlContentHorizontalAlignmentRight  = 2,

    //

    UIControlContentHorizontalAlignmentFill   = 3,

 

};

 

哪些控件有这个属性??

继承自UIControl或者UIControl 本身,如下:

1/UITextField : UIControl <UITextInput, NSCoding, UIContentSizeCategoryAdjusting>

2/UIButton : UIControl <NSCoding>

 

*********************** 三 // contentMode  **************

typedef NS_ENUM(NSInteger, UIViewContentMode) {

    UIViewContentModeScaleToFill,

    UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent

    UIViewContentModeScaleAspectFill,     // contents scaled to fill with fixed aspect. some portion of content may be clipped.

    UIViewContentModeRedraw,              // redraw on bounds change (calls -setNeedsDisplay)

    UIViewContentModeCenter,              // contents remain same size. positioned adjusted.

    UIViewContentModeTop,

    UIViewContentModeBottom,

    UIViewContentModeLeft,

    UIViewContentModeRight,

    UIViewContentModeTopLeft,

    UIViewContentModeTopRight,

    UIViewContentModeBottomLeft,

    UIViewContentModeBottomRight,

 

};

 

继承自 UIView : UIResponder

 

当多个约束出现的时候,按照一/二/三/就近原则,哪个约束就有效

转载于:https://www.cnblogs.com/wzy1/p/6372872.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值