버튼의 텍스트 정렬은 -(TTStyle*)toolbarButtonForState: shape: tintColor: font:
안에 정의되어 있습니다. 따라서이 방법의 자체 버전을 만들어야합니다.
원본을 들여다 보면 추가되는 마지막 스타일로 TTTextStyle이 있습니다.
- (TTStyle*)myButtonForState:(UIControlState)state shape:(TTShape*)shape
tintColor:(UIColor*)tintColor font:(UIFont*)font {
UIColor* stateTintColor = [self toolbarButtonColorWithTintColor:tintColor forState:state];
UIColor* stateTextColor = [self toolbarButtonTextColorForState:state];
return
[TTShapeStyle styleWithShape:shape next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(2, 0, 1, 0) next:
[TTShadowStyle styleWithColor:RGBACOLOR(255,255,255,0.18) blur:0 offset:CGSizeMake(0, 1) next:
[TTReflectiveFillStyle styleWithColor:stateTintColor next:
[TTBevelBorderStyle styleWithHighlight:[stateTintColor multiplyHue:1 saturation:0.9 value:0.7]
shadow:[stateTintColor multiplyHue:1 saturation:0.5 value:0.6]
width:1 lightSource:270 next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(0, -1, 0, -1) next:
[TTBevelBorderStyle styleWithHighlight:nil shadow:RGBACOLOR(0,0,0,0.15)
width:1 lightSource:270 next:
[TTBoxStyle styleWithPadding:UIEdgeInsetsMake(8, 8, 8, 8) next:
[TTImageStyle styleWithImageURL:nil defaultImage:nil
contentMode:UIViewContentModeScaleToFill size:CGSizeZero next:
[TTTextStyle styleWithFont:font color:stateTextColor
minimumFontSize:14.0
shadowColor:[UIColor colorWithWhite:0 alpha:0.4] shadowOffset:CGSizeMake(0, -1)
textAlignment:UITextAlignmentLeft
verticalAlignment:UIControlContentVerticalAlignmentCenter
lineBreakMode:UILineBreakModeWordWrap numberOfLines:1
next:nil]]]]]]]]]];
}
워 =이) 답변 주셔서 감사합니다 : 당신이
그래서 당신의 구현처럼 보일 수 있습니다 편리한 초기화로 textAlignment을 설정하자 TTTextStyle! –