登录 立即注册
金钱:

Code4App-iOS开发-iOS 开源代码库-iOS代码实例搜索-iOS特效示例-iOS代码例子下载-Code4App.com

【Swift】expanding-collection

[复制链接]
来自: shareiOS 分类: iOS精品源码 上传时间: 2016-11-9 11:55:28
Tag:引导页 View Layout Transition 视图切换

项目介绍:

header

expanding-collection

A card peek/pop controller.

关于本项目

Ramotion, Inc 出品.

专注于移动应用程序和网站的自定义UI的设计和编码

[▶︎CONTACT OUR TEAM◀︎]

Animation

The iPhone mockup available here.

环境需求

  • iOS 9.0+

  • Xcode 8

安装方式

只需将Source文件夹添加到您的项目.

或者使用 CocoaPods ,Podfile 文件中添加以下一行:

pod 'expanding-collection', '~> 1.0.3' swift 3

pod 'expanding-collection', '~> 0.3.2' swift 2

or Carthage Cartfile 文件添加以下一行:

github "Ramotion/expanding-collection"

使用方法

import expanding_collection

Create CollectionViewCell

cell

1) Create UICollectionViewCell inherit from BasePageCollectionCell (recommend create cell with xib file)

2) Adding FrontView

  • add a view to YOURCELL.xib and connect it to @IBOutlet weak var frontContainerView: UIView!

  • add width, height, centerX and centerY constraints (width and height constranints must equal cellSize)

cell

  • connect centerY constraint to @IBOutlet weak var frontConstraintY: NSLayoutConstraint!

  • add any desired uiviews to frontView

3) Adding BackView

  • repeat step 2 (connect outlets to @IBOutlet weak var backContainerView: UIView!, @IBOutlet weak var backConstraintY: NSLayoutConstraint!)

4) Cell example DemoCell

If set tag = 101 for any FrontView.subviews this view will be hidden during the transition animation

Create CollectionViewController

1) Create a UIViewController inheriting from ExpandingViewController

2) Register Cell and set Cell size:

override func viewDidLoad() {
    itemSize = CGSize(width: 214, height: 264)
    super.viewDidLoad()

    // register cell
    let nib = UINib(nibName: "NibName", bundle: nil)
    collectionView?.registerNib(nib, forCellWithReuseIdentifier: "CellIdentifier")
}

3) Add UICollectionViewDataSource methods

extension YourViewController {

  override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return items.count
  }

  override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CellIdentifier"), forIndexPath: indexPath)
    // configure cell
    return cell
  }
}

4) Open Cell animation

override func viewDidLoad() {
    itemSize = CGSize(width: 214, height: 264)
    super.viewDidLoad()

    // register cell
    let nib = UINib(nibName: "CellIdentifier", bundle: nil)
    collectionView?.registerNib(nib, forCellWithReuseIdentifier: String(DemoCollectionViewCell))
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    cell.cellIsOpen(!cell.isOpened)
}
if you use this delegates method:
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath)

func scrollViewDidEndDecelerating(scrollView: UIScrollView)
must call super method:
func collectionView(collectionView: UICollectionView, willDisplayCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
  super.collectionView(collectionView: collectionView, willDisplayCell cell: cell, forItemAtIndexPath indexPath: indexPath)
  // code
}

func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
  super.scrollViewDidEndDecelerating(scrollView: scrollView)
  // code
}

Transition animation

1) Create a UITableViewController inheriting from ExpandingTableViewController

2) Set header height default 236

override func viewDidLoad() {
    super.viewDidLoad()
    headerHeight = ***
}  

3) Call the push method in YourViewController to YourTableViewController

  if cell.isOpened == true {
    let vc: YourTableViewController = // ... create view controller  
    pushToViewController(vc)
  }

4) For back transition use popTransitionAnimation()

code4app

相关源码推荐:

我来说两句
*滑动验证:
所有评论(257)
hellokenken 2016-11-9 11:57:11
mark,收藏了
回复
AlonMessi 2016-11-9 11:57:59
mark,收藏了
回复
phoiu 2016-11-9 11:59:28
学习...学习...
回复
littleRed 2016-11-9 12:00:29
不错不错,楼主辛苦了。。。
回复
BlueManlove 2016-11-9 12:01:41
感谢分享,code4app有你更精彩
回复
kengsir 2016-11-9 12:07:06
好好 学习了 确实不错
回复
code4app热心网友 2016-11-9 13:05:22
强烈支持楼主ing……
回复
code4app热心网友 2016-11-9 13:11:41
我只是路过打酱油的。
回复
code4app热心网友 2016-11-9 13:45:31
感谢分享,Code4App有你更精彩:)
回复
提取码:  下载次数:305 状态:已购或VIP 售价:0(原价:10)金钱 下载权限:初级码农 
4820 1 305
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542

如何获得代码达人称号?

代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表