2011-01-05 3 views

答えて

4

独自のコントローラを構築する必要があります。 "このクラス[UITabBarController]はサブクラス化を意図していません"というAppleのドキュメントによると、 UITabBarItemのドキュメントでは、タブバーの画像を「タブバーに表示された画像はこの画像から得られた画像」として提供しています。したがって、タブバーに提供する画像は、タブバー画像の「通常の」外観に合うように操作されます。

したがって、いくつかのUIButtonをサブビューとしてUIViewControllerを構築してから、ルックアンドフィール全体をそのように管理できます。

IMHO、これは多くの利益のために多くの仕事のように思えます。

0

チェックアウトhttps://github.com/xhan/PlutoLandを実行してください。

カスタムPLTabBarControllerクラスを使用すると、そこにカスタムTabBarItemsを割り当てることができます。

0

UITabBarから継承し、drawRectメソッドをオーバーライドすることができます。以下はアイデンティティインスペクタでUITabBarControllerのTabBarのためのカスタムクラスを設定し、それがInterface Builderのに比べて茶色

- (void)drawRect:(CGRect)rect 
{ 
    // Drawing code 
    float baseComponents[] = { 78/255.0, 30/255.0, 0/ 255.0, 1.0 }; 

    // Get current context 
    CGContextRef context = UIGraphicsGetCurrentContext(); 

    // Fill full rectangle 
    CGContextSetRGBFillColor(context, baseComponents[0], baseComponents[1], baseComponents[2], baseComponents[3]); 
    CGContextFillRect(context,rect); 

    // Draw light line on top 
    CGContextSetRGBStrokeColor(context, baseComponents[0] + (67/255.0), baseComponents[1] + (67/255.0), baseComponents[2] + (67/255.0), baseComponents[3]); 
    CGContextMoveToPoint(context, 0, 1); 
    CGPoint points[] = { CGPointMake(0,1.5),CGPointMake(rect.size.width,1.5) }; 
    CGContextStrokeLineSegments(context, points , 2); 

    // Create gradient 
    CGColorSpaceRef myColorspace; 
    CGGradientRef myGradient; 
    size_t num_locations = 2; 
    CGFloat locations[2] = { 0.0, 1.0 }; 
    CGFloat components[8] = { baseComponents[0] + (46/255.0), baseComponents[1] + (46/255.0), baseComponents[2] + (46/255.0), baseComponents[3], // Start color 
    baseComponents[0] + (21/255.0), baseComponents[1] + (21/255.0), baseComponents[2] + (21/255.0), baseComponents[3] }; // End color 

    myColorspace = CGColorSpaceCreateDeviceRGB(); 
    myGradient = CGGradientCreateWithColorComponents (myColorspace, components,locations, num_locations); 

    // Draw gradient 
    CGContextDrawLinearGradient(context, myGradient, CGPointMake(0, 2), CGPointMake(0,rect.size.height/2), 0); 

    // Clean up 
    CGColorSpaceRelease(myColorspace); 
    CGGradientRelease(myGradient); 

} 

に着色されているかのサンプルです。

関連する問題