[textField setTextAlignment:UITextAlignmentLeft]; [textField setTextAlignment:UITextAlignmentCenter]; [textField setTextAlignment:UITextAlignmentRight];之外,還可以針對內容做水平或垂直對齊。
垂直
typedef enum { UIControlContentVerticalAlignmentCenter = 0, UIControlContentVerticalAlignmentTop = 1, UIControlContentVerticalAlignmentBottom = 2, UIControlContentVerticalAlignmentFill = 3, } UIControlContentVerticalAlignment;水平
typedef enum { UIControlContentHorizontalAlignmentCenter = 0, UIControlContentHorizontalAlignmentLeft = 1, UIControlContentHorizontalAlignmentRight = 2, UIControlContentHorizontalAlignmentFill = 3, } UIControlContentHorizontalAlignment;使用方式如下:
//垂直 [textField setContentVerticalAlignment:UIControlContentVerticalAlignmentBottom]; //水平 [textField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
沒有留言:
張貼留言