iOS-仿淘宝navigationBar双波纹(OC版本和Swift版本)

前言

上个月淘宝更新的APP的navigationBar上面有两个大波浪,看着很好玩,很多APP开始模仿,包括我们公司的APP也是,然后我就写了一个播放的View,方便各种环境下使用;

1.navigationBar

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    [self.navigationController.navigationBar addSubview:self.headerView];
    [self.navigationController.navigationBar sendSubviewToBack:self.headerView];
}

- (ZFJWaveView *)headerView{
    if (!_headerView) {
        _headerView = [[ZFJWaveView alloc] initWithFrame:CGRectMake(0, -20, self.view.frame.size.width, 64)];
        _headerView.backgroundColor = [UIColor colorWithRed:1.000 green:0.318 blue:0.129 alpha:1.00];
        _headerView.waveBlock = ^(CGFloat currentY){
        };
        [_headerView startWaveAnimation];
    }
    return _headerView;
}

Swift调用代码

self.view.backgroundColor = UIColor.white
        
        headerView = ZFJWaveView(frame: CGRect(x: CGFloat(0), y: CGFloat(-20), width: CGFloat(self.view.frame.size.width), height: CGFloat(64)))
        headerView.backgroundColor = UIColor(red: CGFloat(1.000), green: CGFloat(0.318), blue: CGFloat(0.129), alpha: CGFloat(1.00))
        headerView.waveBlock = {(_ currentY: CGFloat) -> Void in
            //print(currentY)
        }
        headerView.startWaveAnimation()
        
        self.navigationController!.navigationBar.addSubview(headerView)
        self.navigationController!.navigationBar.sendSubview(toBack: headerView)


效果如下:



2.其他(UITableview头部)

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.backgroundColor = KBackgroundColor;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.separatorColor = [UIColor clearColor];
        _tableView.tableHeaderView = self.headerView;
    }
    return _tableView;
}

- (ZFJWaveView *)headerView{
    if (!_headerView) {
        _headerView = [[ZFJWaveView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 265)];
        __weak typeof(self)weakSelf = self;
        _headerView.titleName = @"小荧星培训机构";
        _headerView.detailName = @"机构ID:134611";
        _headerView.btnTittleArr = @[@"主页",@"比赛"];
        _headerView.selectType = ^(NSInteger selectIndex,NSString *selectIndexTitle){
            weakSelf.selectType = selectIndex;
        };
        [_headerView startWaveAnimation];
        [_headerView addSubview:weakSelf.headViewBackBtn];
    }
    return _headerView;
}
效果如下:


3.DEMO下载

OC版本点击下载

OC版本:http://download.csdn.net/detail/u014220518/9731412


Swift版本点击下载

Swift版本:http://download.csdn.net/detail/u014220518/9732721





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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值