Giter VIP home page Giter VIP logo

dysegmentdemo's Introduction

DYSegmentDemo

喜欢的朋友可以下载下来,如果代码对你有所帮助,还请给个Star,非常感谢你的支持!

  • 选择滑动控件

  • 实现功能:滑动切换,点击切换,字体颜色渐变,标题选中和未选中时的逐渐形变。

  • 效果图

image

  • 对应文件

  • DYSegmentView : 自定义滑动控件实现类

  • 具体使用


-(DYSegmentView *)dySegment{
    if (!_dySegment) {
        _dySegment = [[DYSegmentView alloc]initWithFrame:CGRectMake(ScreenWidth/2-120, 25, 240, 44)];
        _dySegment.delegate         = self;
        _dySegment.backgroundColor  = [UIColor clearColor];
        _dySegment.titleNormalColor = UIColorFromRGB(0xffffff, 0.5);
        _dySegment.titleSelectColor = UIColorFromRGB(0xffffff, 0.9);
        _dySegment.titleFont        = [UIFont systemFontOfSize:15];
        _dySegment.titleArray       = @[@"在线",@"附近"];
    }
    return _dySegment;
}
    self.navigationItem.titleView = self.dySegment;
  • 实现相对应的代理方法 <DYSegmentDelegate,UIScrollViewDelegate>

#pragma mark - UIScrollDelegate
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [_dySegment dyDidScrollChangeTheTitleColorWithContentOfSet:scrollView.contentOffset.x];
}
#pragma mark - DYSegmentDelegate
-(void)dySegment:(DYSegmentView *)segment didSelectIndex:(NSInteger)index{
    NSString *notiStr;
    if (index == 1) {
        notiStr = @"1";
    }else{
        notiStr = @"2";
    }
    self.scrollView.contentOffset = CGPointMake(ScreenWidth*(index-1), 0);
    [[NSNotificationCenter defaultCenter] postNotificationName:@"MainViewScrollDidScroll" object:notiStr];
}
  • 使用过程中有问题请加QQ或发邮件:584379066 备注:Git SegmentView

dysegmentdemo's People

Contributors

danielyk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.