-
使用collectionView
-
UIcollectionViewlayout 自定义prepared 调用顺序,1.count,2.准备布局,3.返回cell
-
重写init 方法,设置外部参数照片的数组,
-
一个文件中可以创建多个class ,创建类flowLyout. newFertureCell
-
NewfeatureLayout 中prepareLayout() 方法 设置layout的参数,和collectionView的参数
-
什么时候调用? 1.先调用一个有多少行cell 2.调用准备布局 3.调用返回cell
override func prepareLayout() { // 1.设置layout布局 itemSize = UIScreen.mainScreen().bounds.size minimumInteritemSpacing = 0 minimumLineSpacing = 0 scrollDirection = UICollectionViewScrollDirection.Horizontal // 2.设置collectionView的属性 collectionView?.showsHorizontalScrollIndicator = false collectionView?.bounces = false collectionView?.pagingEnabled = true } -
cell 中设置button 显示的动画,设置button的点击发送通知
-
设置** transform** 动画,完成之后 transform 设置 CGAffineTransform.identity ,归位初始值
-
usingSpringWithDamping 为(0-1), 数值越小,弹力越大
-
initialSpringVelocity 速度 5,10,15
// button的动画 func buttonStartAnimation(){ cellButton.isHidden = false cellButton.transform = CGAffineTransform(scaleX: 0, y: 0); cellButton.isUserInteractionEnabled = false UIView.animate(withDuration: 2, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 10, options: UIViewAnimationOptions.init(rawValue: 0), animations: { self.cellButton.transform = CGAffineTransform.identity }) { (_) in self.cellButton.isUserInteractionEnabled = true } } -
swift 3.0 之发送通知
-
创建一个swift文件,存储常量,
-
通知变化为 NSNotification.Name(rawValue:"")
// 发送通知 let SwitchRootVCNotification = NSNotification.Name(rawValue:"SwitchRootViewControllerKey") NotificationCenter.default.post(name:SwitchRootVCNotification, object: nil) // 接收通知 NotificationCenter.default.addObserver(self, selector: #selector(changeRoot), name: SwitchRootVCNotification, object: nil)