Image on UITabBar gets distributed

Hey, I'm using a custom size UITabBar with very large images.

I add images to the tab bar item as follows:

UITabBar *tabBar = self.tabBar;
    UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
    [tabBarItem1 setImage:[UIImage imageNamed:@"image"]];
    [tabBarItem1 setImageInsets:UIEdgeInsetsMake(0, 0, 20, 0)];

Also, since the images are larger, I want them to hang more in the middle of the tab bar, so I am adding an insert.

My problem is that I program the insert, and then I press the button, the button starts itself. It maintains its width, but its height permeates it. Of course, I do not want this to happen, but I cannot understand what is happening.

Thanks Krtko

-Note for Mods Please block this topic

-Note for people answering my question. I appreciate your help, but at that time it was a known mistake, so please stop answering this question. thank you

+4
5

iOS 7?

7.1, , . , . , ?

+14

UIEdgeInsetsMake "BE EQUAL" . : item.imageInsets = UIEdgeInsetsMake (6, 0, -6, 0);

+7

. , . , Apple .

0

UIView UITapGestureReognizer UIView. , , , . Hack, , .

 @property UIView  tabBarCover;//place on top of uitabbar and give it clear color background

 - (void)viewDidLoad
 {
   [tabBar setSelectedItem:[tabBar.items objectAtIndex:0]];
    UITapGestureRecognizer *singleFingerTap =
                        [[UITapGestureRecognizer alloc] initWithTarget:self
                                        action:@selector(handleSingleTap:)];
   [tabBarCover addGestureRecognizer:singleFingerTap];

 }

, UIView , , . 3 , x.

-(void) handleSingleTap:(UITapGestureRecognizer *) recognizer
{
    CGPoint location = [recognizer locationInView:[recognizer.view superview]];
    //NSLog(@"tapped it %lf", location.x);
    if(location.x<=105){
        //1st 3rd tapped, do something

    }
    else if(location.x >105 && location.x<=210)
    {
       //do nothing, selected item stays same. this is glas
    }else{
       //must be in 3rd section so do that load

    }

}

, .

0

, ios7 setFrame

  • (void) tabBarController: (UITabBarController *) tabBarController SelectViewController: (UIViewController *) viewController
0

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


All Articles