Giter VIP home page Giter VIP logo

jrsegmentcontrol's Introduction

JRSegmentControl

一个类似于UISegmentControl的自定义控制,可以点击和滑动来切换不同的选项。同时封装了JRSegmentViewController可以方便集成类似于《猫眼电影》中的切换效果。


JRSegmentControl


使用方法

(一)
#import "JRSegmentViewController.h"

初始化视图控制器,并设置viewControllers属性,如:

	JRSegmentViewController *vc = [[JRSegmentViewController alloc] init];
    vc.segmentBgColor = [UIColor colorWithRed:18.0f/255 green:50.0f/255 blue:110.0f/255 alpha:1.0f];
    vc.indicatorViewColor = [UIColor whiteColor];
    vc.titleColor = [UIColor whiteColor];
    
    [vc setViewControllers:@[firstVC, secondVC, thirdVC]];
    [vc setTitles:@[@"热点", @"聚焦", @"推荐"]];
    
    [self.navigationController pushViewController:vc animated:YES];

以上方法可以实现Demo中的效果,可参考Demo。

(二)

单独使用 JRSegmentControl,使用方法类似 UISegmentControl

#import "JRSegmentControl"
	JRSegmentControl *segment = [[JRSegmentControl alloc] initWithFrame:CGRectMake(0, 0, _itemWidth * 3, 30.0f)];
    segment.titles = @[@"热点", @"聚焦", @"推荐"];
    segment.cornerRadius = 5.0f;
    segment.titleColor = [UIColor whiteColor];
    segment.indicatorViewColor = [UIColor whiteColor];
    segment.backgroundColor = [UIColor colorWithRed:18.0f/255 green:50.0f/255 blue:110.0f/255 alpha:1.0f];
    
    segment.delegate = self; // 遵守协议即可
    
    [self.view addSubView:segment];

jrsegmentcontrol's People

Contributors

zhanjiarong avatar

Watchers

James Cloos 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.