Iphone Custom UITabBarItem without rounded edges

I am trying to configure uitabbar

i is an extended uitabbar element and now has a customized image, but I can not get rid of rounded edges.

the code:

@interface CustomTabBarItem : UITabBarItem  
{
    UIImage *customHighlightedImage;
}

@property (nonatomic, retain) UIImage *customHighlightedImage;

@end

@implementation CustomTabBarItem

@synthesize customHighlightedImage;

- (void) dealloc
{
    [customHighlightedImage release]; customHighlightedImage=nil;
    [super dealloc];
}

-(UIImage *) selectedImage
{
    return self.customHighlightedImage;
}

@end

Maybe somoen knows how to get rid of a rounded rectangle

around the image

thanks in advance Alex

+3
source share
5 answers

thanks for solving it using custom tab bar items

DOES NOT APPROVED.

goes to tabController1.m

    - (id) init
{   
    if(self = [super init])
    {
        CustomTabBarItem *tabItem = [[CustomTabBarItem alloc]
                                     initWithTitle:@"" image:nil tag:0];

        tabItem.customHighlightedImage=[UIImage imageNamed:TABBAR_TAB_4_ACTIVE];
        tabItem.customStdImage=[UIImage imageNamed:TABBAR_TAB_4_DEFAULT];       

        self.tabBarItem=tabItem;
        [tabItem release]; 
        tabItem=nil;    
    }
    return self;
}

cutom tabbaritem:

@interface CustomTabBarItem : UITabBarItem  
{
    UIImage *customHighlightedImage;
    UIImage *customStdImage;
}

@property (nonatomic, retain) UIImage *customHighlightedImage;
@property (nonatomic, retain) UIImage *customStdImage;

@end

#import "CustomTabBarItem.h"


@implementation CustomTabBarItem

@synthesize customHighlightedImage;
@synthesize customStdImage;

- (void) dealloc
{
    [customHighlightedImage release]; customHighlightedImage=nil;
    [customStdImage release]; customStdImage=nil;   
    [super dealloc];
}

-(UIImage *) selectedImage
{
    return self.customHighlightedImage;
}

-(UIImage *) unselectedImage
{
    return self.customStdImage;
}

@end
+3
source

It's dirty, but it works and got approval:

  • resizes tabs
  • use your own images in your own size

in setting up the tablet controller

    tabController   = [[UITabBarController alloc] init];
tabController.view.frame = CGRectMake(0, 72, 320, 480 - (82));
tabController.delegate = self;
UIImageView *bgImageView;
bgImageView = [ [ UIImageView alloc ] initWithImage: [UIImage imageNamed:TABBAR_BACKGROUND]];
bgImageView.frame = CGRectMake(0, -11, 320, 60);

[[tabController tabBar] addSubview:bgImageView];
[[tabController tabBar] sendSubviewToBack:bgImageView];
tabController.tabBar.frame = CGRectMake(0, 460 - (59 + 52 - 11), 320, 49);
[bgImageView release];

[window addSubview:tabController.view];

init tabcontroller1

   - (id) init
{
    if(self = [super init])
    {       
        CustomTabBarItem *tabItem = [[CustomTabBarItem alloc]
                                     initWithTitle:@"" image:nil tag:0];

        tabItem.customHighlightedImage=[UIImage imageNamed:TABBAR_TAB_1_ACTIVE];
        tabItem.customStdImage=[UIImage imageNamed:TABBAR_TAB_1_DEFAULT];       

        self.tabBarItem=tabItem;
        [tabItem release]; 
        tabItem=nil;
    }

return self;
}

    @interface CustomTabBarItem : UITabBarItem  
    {
        UIImage *customHighlightedImage;
        UIImage *customStdImage;
    }

    @property (nonatomic, retain) UIImage *customHighlightedImage;
    @property (nonatomic, retain) UIImage *customStdImage;

    @end

#import "CustomTabBarItem.h"


@implementation CustomTabBarItem

@synthesize customHighlightedImage;
@synthesize customStdImage;

- (void) dealloc
{
    [customHighlightedImage release]; customHighlightedImage=nil;
    [customStdImage release]; customStdImage=nil;   
    [super dealloc];
}

-(UIImage *) selectedImage
{
    return self.customHighlightedImage;
}

-(UIImage *) unselectedImage
{
    return self.customStdImage;
}

@end

:

iphone shure, . , , , .

+4

cornerRadius 0:

view.layer.cornerRadius = 0;

, #include CALayer:

#import <QuartzCore/QuartzCore.h>
+1

.

/ API,

-(UIImage *) selectedImage {
    return self.customHighlightedImage; }

-(UIImage *) unselectedImage {
    return self.customStdImage; }

CustomTabBarItem.

These methods are undocumented / hidden methods in the UITabBarItem class and are overridden in the CustomTabBarItem class .

Is it possible to override undocumented methods?

I still wonder how it is approved by Apple. I need some clarification.

+1
source

Any other Apple approved apps with this code? It is very interesting to know if we are allowed to use the selectedImage and unselectedImage methods.

0
source

Source: https://habr.com/ru/post/1744958/


All Articles