2012-02-11 21 views
2

我一直在寻找复制,Facebook的使用在这里他们的应用程序的按钮格栏:复制Facebook的使用three20 TTButtonBar,iOS的

enter image description here

左边的按钮是未按下,右边被按下。

我无法复制“推送”按钮状态。谁能帮忙?以下是我到目前为止有:

enter image description here

我很满意,大部分。只需要刷新按钮的大小,但这是微不足道的。在我的工具栏上,左边的按钮应该是推动的,右边的不是。很明显,我错过了Facebook上实现的顶部投影。我怎样才能复制这个?我正在考虑使用TTInnerShadowStyle,但似乎无法做到。这里是生成每个按钮的样式代码:

UIColor *gradientFill1 = RGBCOLOR(249, 250, 252),*gradientFill2 = RGBCOLOR(225, 228, 235); 

if (state != UIControlStateNormal) { 
    gradientFill1 = RGBCOLOR(233, 234, 237); 
    gradientFill2 = RGBCOLOR(214, 217, 223); 
} 

TTStyle *style= [TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:3] next: 
     [TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 0, 1, 0) next: 
     [TTLinearGradientBorderStyle styleWithColor1:RGBCOLOR(140, 144, 150) 
               color2:RGBCOLOR(175, 179, 186) width:0.5 next: 
     [TTLinearGradientBorderStyle styleWithColor1:RGBCOLOR(184, 186, 192) 
               color2:RGBCOLOR(208, 212, 218) width:0.5 next: 
      [TTLinearGradientFillStyle styleWithColor1:gradientFill1 
               color2:gradientFill2 next: 
      [TTShadowStyle styleWithColor:RGBACOLOR(253,254,254,1.0) blur:0 
            offset:CGSizeMake(0, 1) next: 
       [TTImageStyle styleWithImageURL:nil defaultImage:nil 
           contentMode:UIViewContentModeScaleToFill 
             size:CGSizeZero next: 
       [TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:12.0f] 
           color:RGBCOLOR(81, 91, 120) 
          shadowColor:nil 
         shadowOffset:CGSizeMake(0, 0) next:nil]]]]]]]]; 


return style; 

任何帮助将不胜感激。谢谢!

回答

1

事实上,当您添加TTInnerShadowStyle时,您的代码会显得有点奇怪。但是,这似乎是由你的双边框样式造成的。

如果在填充后插入内部阴影,然后移动两个渐变边框,请隐藏内部阴影,它看起来完全如预期。内部较亮的边框看起来错位。

我会推荐使用“Chiseled按钮”和TTCatalog中的“内部阴影”示例的组合。这可能是这样的:

[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:3] next: 
[TTShadowStyle styleWithColor:RGBACOLOR(255,255,255,0.9) blur:1 
         offset:CGSizeMake(0, 1) next: 
[TTLinearGradientFillStyle styleWithColor1:gradientFill1 
          color2:gradientFill2 next: 
[TTInnerShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.7) blur:7 
          offset:CGSizeMake(0, 0) next: 
[TTSolidBorderStyle styleWithColor:black width:1 next: 
[TTImageStyle styleWithImageURL:nil defaultImage:nil 
        contentMode:UIViewContentModeScaleToFill 
          size:CGSizeZero next:      
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:12.0f] 
        color:RGBCOLOR(81, 91, 120) 
       shadowColor:nil 
       shadowOffset:CGSizeMake(0, 0) next:nil]]]]]]] 

对于正常状态只需设置内阴影颜色为透明的,或有条件避免内部的阴影彻底。

0

你可以做的是去直接的方式,并通过CoreGraphics实现内部的阴影效果。看看S.O. page

+0

谢谢这可以工作。我正在寻找一种方法来完成它,同时仍然使用'TTButtonBar',而不必添加比所需更多的代码。想知道如果那是我的陷阱。 – ecbtln 2012-02-11 20:47:25