[Swift] expanding-collection - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
newkengsir
V2EX    问与答

[Swift] expanding-collection

  •  
  •   newkengsir 2016-11-10 10:36:24 +08:00 2370 次点击
    这是一个创建于 3260 天前的主题,其中的信息可能已经有所发展或是发生改变。

    header

    expanding-collection

    http://www.code4app.com/forum.php?mod=viewthread&tid=11428&extra=page%3D1%26filter%3Dsortid%26sortid%3D1

    https://github.com/Ramotion/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
    1. Adding BackView
    • repeat step 2 (connect outlets to @IBOutlet weak var backContainerView: UIView!, @IBOutlet weak var backConstraintY: NSLayoutConstraint!)
    1. 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") } 
    1. 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 } } 
    1. 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 = *** } 
    1. Call the push method in YourViewController to YourTableViewController
     if cell.isOpened == true { let vc: YourTableViewCOntroller= // ... create view controller pushToViewController(vc) } 
    1. For back transition use popTransitionAnimation()
    目前尚无回复
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2876 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 14:28 PVG 22:28 LAX 07:28 JFK 10:28
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86