自定义tablebar



//  TablebarView.h


#import <UIKit/UIKit.h>

#pragma mark - 延展

@protocol TablebarViewDelegate <NSObject>


- (void)tablebarViewDelegate:(NSInteger )tag;


@end


@interface TablebarView : UIView


@property (nonatomic, strong) id<TablebarViewDelegate>delegate;

@property (nonatomic, strong) UIButton *button1;

@property (nonatomic, strong) UIButton *button2;

@property (nonatomic, strong) UIButton *button3;

@property (nonatomic, strong) UIButton *button4;

@property (nonatomic, strong) UIButton *button5;


@end




//  TablebarView.m

#import "TablebarView.h"

#define W [UIScreen mainScreen].bounds.size.width


@implementation TablebarView


- (instancetype)initWithFrame:(CGRect)frame {

    self = [super initWithFrame:frame];

    if (self) {

        

        self.backgroundColor = [UIColor colorWithRed:233/255.f green:156/255.f blue:175/255.f alpha:1];

        

        self.button1 = [UIButton buttonWithType:UIButtonTypeCustom];

        self.button1.frame = CGRectMake(10, 0, W / 5 - 5 , 44);

        [self.button1 setImage:[UIImage imageNamed:@"home"] forState:UIControlStateNormal];

        self.button1.tag = 1;

        [self.button1 addTarget:self action:@selector(tableBarDelegate:) forControlEvents:UIControlEventTouchUpInside];

        [self addSubview:self.button1];

        

        self.button2 = [UIButton buttonWithType:UIButtonTypeCustom];

        self.button2.frame = CGRectMake(W / 5 + 5  , 0, W / 5 - 5, 44);

        [self.button2 setImage:[UIImage imageNamed:@"搜索"] forState:UIControlStateNormal];

        self.button2.tag = 2;

        [self.button2 addTarget:self action:@selector(tableBarDelegate:) forControlEvents:UIControlEventTouchUpInside];

        [self addSubview:self.button2];

        

        self.button3 = [UIButton buttonWithType:UIButtonTypeCustom];

        self.button3.frame = CGRectMake(W / 2 - W / 5 / 2 , 0, W / 5 , 44);

        [self.button3 setImage:[UIImage imageNamed:@"相机"] forState:UIControlStateNormal];

        self.button3.tag = 3;

        [self.button3 addTarget:self action:@selector(tableBarDelegate:) forControlEvents:UIControlEventTouchUpInside];

        [self addSubview:self.button3];

        

        self.button4 = [UIButton buttonWithType:UIButtonTypeCustom];

        self.button4.frame = CGRectMake(W / 2 - W / 5 / 2 + W / 5, 0, W / 5 - 5, 44);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值