各种内容对齐 总结

********************** 一 //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

 

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

posted @ 2017-02-07 10:20  王卓越  阅读(488)  评论(0编辑  收藏  举报