2012-07-27 1 views
0

를 사용 TTButton 내의 텍스트 위에있는 이미지는 다음과 같이 표시합니다 :Three20 : 나는 TTButton 스타일을 시도하고 TTStyles

http://tinypic.com/r/29c3oyh/6

당신은 이미지와 텍스트를 정렬 모두 센터입니다 것을 알 수 있습니다 TTButton 내에서 이미지가 텍스트 위에 있음을 나타냅니다. TTBoxStyle의 조합과 순서에 관계없이 이미지와 텍스트를 동시에 정렬 할 수는 없습니다.

- (TTStyle*)happyfaceIcon:(UIControlState)state { 
return [TTImageStyle styleWithImageURL:nil defaultImage:nil contentMode:UIViewContentModeCenter size:CGSizeMake(40, 40) next: 
     [TTBoxStyle styleWithMargin:UIEdgeInsetsMake(0, 20, 0, 0) next:nil]]; 
} 

- (TTStyle*)happyfaceButton:(UIControlState)state { 
return [TTShapeStyle styleWithShape:[TTRectangleShape shape] next: 
     [TTSolidBorderStyle styleWithColor:[UIColor blackColor] width:1 next: 
     [TTSolidFillStyle styleWithColor:[UIColor grayColor] next: 
      [TTBoxStyle styleWithMargin:UIEdgeInsetsMake(45, 2, 5, 2) next: 
      [TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:10] 
           color:[UIColor blackColor] textAlignment:UITextAlignmentCenter next: 
      [TTPartStyle styleWithName:@"image" style:TTSTYLESTATE(happyfaceIcon:, state) next: nil 
      ]]]]]]; 
} 

답변

1

글쎄 그것은 아주 간단합니다. 답변을보기 위해 TTLauncherButton을 살펴 보았습니다.

기본적으로 TTButton 속성 isVertical = YES가 모든 문제를 해결했습니다. 사람이 관심이 있다면

여기뿐만 아니라 내 마지막 스타일의

- (TTStyle*)shortcutIcon:(UIControlState)state { 
TTStyle* style = 
[TTBoxStyle styleWithMargin:UIEdgeInsetsMake(-7, 0, 11, 0) next: 
    [TTImageStyle styleWithImageURL:nil defaultImage:nil contentMode:UIViewContentModeCenter 
          size:CGSizeZero next:nil]]; 

if (state == UIControlStateHighlighted || state == UIControlStateSelected) { 
    [style addStyle: 
    [TTBlendStyle styleWithBlend:kCGBlendModeSourceAtop next: 
     [TTSolidFillStyle styleWithColor:RGBACOLOR(0,0,0,0.5) next:nil]]]; 
} 

return style; 
} 

- (TTStyle*)shortcutButton:(UIControlState)state { 
return 
[TTPartStyle styleWithName:@"image" style:TTSTYLESTATE(shortcutIcon:, state) next: 
[TTTextStyle styleWithFont:[UIFont fontWithName:@"Frutiger-Light" size:15] color:TTSTYLEVAR(shortcutTextColor) 
      minimumFontSize:11 shadowColor:nil 
       shadowOffset:CGSizeZero next:nil]]; 
}