Giter VIP home page Giter VIP logo

xlcardswitch's Introduction

XLCardSwitch

利用余弦函数的曲线特性实现的图片居中放大浏览工具,内部是利用UICollectionview的滚动实现的,有兴趣的可以看一下我的博文,里面有具体的实现原理,还是挺好玩儿的。本工具也只是想传递这个这个居中放大的算法,为了方便使用也做了些功能性的封装;

功能

  • 手指拖动切换卡片
  • 调用方法切换卡片
  • 可设置是否分页滚动

效果

正常滑动 分页滑动 调用方法切换
image image image

使用方法

创建方法:

    //设置卡片浏览器
    _cardSwitch = [[XLCardSwitch alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height - 64)];
    _cardSwitch.items = items;
    //设置代理
    _cardSwitch.delegate = self;
    //设置是否打开分页滑动
    _cardSwitch.pagingEnabled = true;
    //设置初始位置,默认为0
    _cardSwitch.selectedIndex = 3;
    [self.view addSubview:_cardSwitch];

切换位置:

[_cardSwitch switchToIndex:3 animated:true];

_cardSwitch.selectedIndex = 3;

代理方法:

- (void)XLCardSwitchDidSelectedAt:(NSInteger)index {
    NSLog(@"选中了:%zd",index);
}

实现原理请参考我的博文

个人开发过的UI工具集合 XLUIKit

xlcardswitch's People

Contributors

mengxianliang avatar

Watchers

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