首页 > 移动平台 > 详细

ios 自定义tabbar

时间:2014-09-20 14:21:29      阅读:291      评论:0      收藏:0      [点我收藏+]

.h文件:

#import <UIKit/UIKit.h>

@interface YLYTabBar : UIView

@end

.m文件

#import "YLYTabBar.h"

@implementation YLYTabBar

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 1.设置背景色
        self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithNamed:@"tabbar_background"]];
        
    }
    return self;
}

使用:

-(void)addTabBar
{
    YLYTabBar *myTabBar = [[YLYTabBar alloc] init];
    myTabBar.frame = self.tabBar.bounds;
    [self.tabBar addSubview:myTabBar];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //移除之前的4各UITabBarButton
    for (UIView *child in self.tabBar.subviews) {
        if ([child isKindOfClass:[UIControl class]]) {
            [child removeFromSuperview];
        }
    }
}

 

ios 自定义tabbar

原文:http://www.cnblogs.com/yuanliyong520/p/3983214.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!