开发者

Custom colored UITabBar icons

开发者 https://www.devze.com 2023-01-28 16:56 出处:网络
Im trying to implement custom colors in UITabBar.But i dont know what the problem is.I placed an image on 1 tabBar.when the tabBar is active,i want one image and when tabBar is inactive,i want another

Im trying to implement custom colors in UITabBar.But i dont know what the problem is.I placed an image on 1 tabBar.when the tabBar is active,i want one image and when tabBar is inactive,i want another image to be displayed on the same tabBar.How? Also guide me that the image is placed at the center of the tabBar.Please tell me the Xcode for this implementation-(void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

for(UIView *view in self.tabBarController.tabBar.subviews) {

if([view isKindOfClass:[UIImageView class]]) {

[view removeFromSuperview];

}

}

[self.tabBarController.tabBar insertSubvi开发者_高级运维ew:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Icon-a.png"]] autorelease] atIndex:0];  

}

  • (void)viewWillDisappear:(BOOL)animated { //[superviewWillDisappear:animated]; for(UIView *view in self.tabBarController.tabBar.subviews) {

    if([view isKindOfClass:[UIImageView class]]) {

    [view removeFromSuperview];

    }

    }

    [self.tabBarController.tabBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Icon-c.png"]] autorelease] atIndex:0];

    }

    I used these methods to implement my task.But i coudn't get the solution.Please help me


You may refer the source code available in the following link, Hope it will fix your problem.. https://github.com/rumex/RXCustomTabBar

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号