我该如何设置?
func isChecked(){ let window = UIApplication.sharedApplication().keyWindow window!.addSubvIEw(collectionVIEw) let height: CGfloat = 250 let y = window!.frame.height - 250 collectionVIEw.frame = CGRect(x: 0,y: window!.frame.height,wIDth: window!.frame.wIDth,height: height) UIVIEw.animateWithDuration(0.5,delay: 0,usingSpringWithdamPing: 1,initialSpringVeLocity: 1,options: .CurveEaSEOut,animations: { self.collectionVIEw.frame = CGRectMake(0,y,self.collectionVIEw.frame.wIDth,self.collectionVIEw.frame.height) },completion: nil)}func isUnchecked(){ let window = UIApplication.sharedApplication().keyWindow UIVIEw.animateWithDuration(0.3,window!.frame.height,self.collectionVIEw.frame.height) })}
有没有办法可以完成我上面的工作,除了我在故事板中创建的视图?
解决方法 我为你做了一个小小的演示:创建了新项目并在VIEwController.swift中编写了该代码,仅此而已.认为这有帮助import UIKitclass VIEwController: UIVIEwController { let collectionVIEw: UICollectionVIEw = { let frame = CGRect(x: 0,y: 50,wIDth: UIScreen.mainScreen().bounds.size.wIDth,height: UIScreen.mainScreen().bounds.size.height - 50) let col = UICollectionVIEw(frame: frame,collectionVIEwLayout: UICollectionVIEwFlowLayout()) col.layer.bordercolor = UIcolor.redcolor().CGcolor col.layer.borderWIDth = 1.0 col.backgroundcolor = UIcolor.yellowcolor() return col }() let switchVIEw = UISwitch() func switched(s: UISwitch){ let origin: CGfloat = s.on ? vIEw.frame.height : 50 UIVIEw.animateWithDuration(0.35) { self.collectionVIEw.frame.origin.y = origin } } overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() switchVIEw.frame = CGRect(x: 0,y: 20,wIDth: 40,height: 20) switchVIEw.addTarget(self,action: #selector(switched),forControlEvents: .ValueChanged) vIEw.addSubvIEw(switchVIEw) vIEw.addSubvIEw(collectionVIEw) }}总结
以上是内存溢出为你收集整理的ios – 在Swift中从底部查看幻灯片?全部内容,希望文章能够帮你解决ios – 在Swift中从底部查看幻灯片?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)