GithubHelp home page GithubHelp logo

mengxianliang / xlcardswitch Goto Github PK

View Code? Open in Web Editor NEW
385.0 8.0 75.0 18.46 MB

iOS 利用余弦函数特性实现可以居中放大的图片浏览工具

Objective-C 48.81% Swift 51.19%
switch scale card scroll

xlcardswitch's Issues

有点问题想请教一下大大优化一下

就是公司需要类似的效果,但是还有一个多的要求,就是一进页面,会指定某个图片在中间这样显示,是否是使用类似于与collectionview scrollToItemAtIndexPath:<#(nonnull NSIndexPath *)#> atScrollPosition:<#(UICollectionViewScrollPosition)#> animated:<#(BOOL)#>方法,或者selectItemAtIndexPath:<#(nullable NSIndexPath *)#> animated:<#(BOOL)#> scrollPosition:<#(UICollectionViewScrollPosition)#>

自定义item的大小

博主你好,最近这需要实现这样的一个效果,但是要自定义每个item的大小,collectionView的宽度为屏幕宽度,item大小60*60,你的这个应该怎样定制呢

切换时会出现图片的闪动

attributes.transform = CGAffineTransformMakeScale(1.0, scale);只实现了高度的缩放,所以闪动情况不明显。
当把attributes.transform改成attributes.transform = CGAffineTransformMakeScale(scale, scale);的时候,宽度也进行了缩放,闪动情况就更加明显了。
我研究了下,是因为cell重用的机制,导致从缓冲区里拿出来的cell,原先切换时设置的transform被还原了,但是找不到解决方案

当只有2个卡片时,从第一个卡片滑动到第二个卡片,第二个卡片的点击事件被滑动事件拦截了,卡片大于2个就没有问题了

//手指拖动开始

  • (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {

    _dragStartX = scrollView.contentOffset.x;
    }

//手指拖动停止

  • (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    if (_pagingEnabled) {return;}
    _dragEndX = scrollView.contentOffset.x;
    dispatch_async(dispatch_get_main_queue(), ^{
    [self fixCellToCenter];
    });
    }

被这两个方法拦截了点击事件

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.