Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Three20:使用TTStyles的TTButton中文本上方的图像_Objective C_Uibutton_Three20 - Fatal编程技术网

Objective c Three20:使用TTStyles的TTButton中文本上方的图像

Objective c Three20:使用TTStyles的TTButton中文本上方的图像,objective-c,uibutton,three20,Objective C,Uibutton,Three20,我试图将TTButton的样式设置为如下所示: 您会注意到,图像和文本都在TTButton内居中对齐,并且图像位于文本上方。无论TTBoxStyle和排序的组合如何,我似乎都无法同时获得图像和文本的正确对齐方式 - (TTStyle*)happyfaceIcon:(UIControlState)state { return [TTImageStyle styleWithImageURL:nil defaultImage:nil contentMode:UIViewContentModeCent

我试图将TTButton的样式设置为如下所示:

您会注意到,图像和文本都在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
             ]]]]]];
}

嗯,这似乎是相当直截了当的。我只需要看一下TTLauncher按钮就可以看到答案

基本上TTButton属性isVertical=是清除了所有问题

如果有人感兴趣,这也是我最后的风格

- (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]];
}