Git Product home page Git Product logo

klpageviewcontroller's Introduction

KLPageViewController

这个组件用于快速创建一个pageVIewController。

一、特性

  1. 快速创建。只需要把包含子控制器的数组传过去即可。
- (instancetype)initWithViewControllers:(NSArray<UIViewController *> *)viewControllers
  1. 可以可选的指定一个SegmentedView,并指定其放置位置。
- (instancetype)initWithViewControllers:(NSArray<UIViewController *> *)viewControllers
segmentedView:(nullable UIView<KLSegmentedViewProtocol> *)segmentedView
segmentedViewPosition:(KLSegmentedViewPosition)position;
  1. SegmentedView可定制化,只需遵循一个协议即可。
// 如果你想自定义KLSegmentedView,你只需要实现这个协议即可。
@protocol KLSegmentedViewProtocol <NSObject>
@required
@property (nonatomic, weak) id <KLSegmentedViewDelegate> delegate;
- (void)selectedItemAtIndex:(NSInteger)index;
@end

二、用法

NSArray *vcs = @[vc1, vc2, vc3, vc4, vc5, vc6];
NSArray *titles = @[@"按钮1", @"按钮2", @"按钮3", @"按钮4", @"按钮5", @"按钮6"];

KLSegmentedView *segView = [[KLSegmentedView alloc] initWithTitles:titles frame:CGRectMake(0, 0, KLScreenWidth, 44.0)];
//    segView.itemSpacing = 10.0;
//    segView.marginLeft = 20.0;
//    segView.marginRight = 50.0;
segView.extraItemWidth = 20.0;
//    segView.fixedItemWidth = 100.0;
//    [segView setItemTextFont:KLFontMedium(17) forState:UIControlStateNormal];

KLSegmentedViewController *segVc = [[KLSegmentedViewController alloc] initWithViewControllers:vcs segmentedView:segView segmentedViewPosition:KLSegmentedViewPositionTop];

[self addChildViewController:segVc];
[self.view addSubview:segVc.view];
[segVc didMoveToParentViewController:self];
[segVc.view mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.right.bottom.offset(0);
    make.top.mas_equalTo(self.mas_topLayoutGuideBottom);
}];

三、

由于时间有限,这个小组件是从公司代码里面分离出来的,定制化可能不是非常高,但是基本可以满足现在大部分app的需求。 如果使用中有什么问题,可以给我提issue。或者加我微信:16621130658。 感谢!

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.