2
如果我的故事板中有一個視圖設置,當按下按鈕時,有沒有一種方法可以使我的視圖(自定義寬度和高度)從屏幕底部向上滑動?我想讓屏幕重疊(這樣你仍然可以按下屏幕下方的東西)。讓View從底部滑入Swift中?
我該如何設置?
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, animations: {
self.collectionView.frame = CGRectMake(0, window!.frame.height, self.collectionView.frame.width, self.collectionView.frame.height)
})
}
有沒有一種方法可以完成我在上面做的事情,除了我在故事板中創建的視圖?
你嘗試過什麼?這可以通過多種方式完成,包括框架或自動佈局,UIView動畫等。 – paulvs
沒有默認的過渡樣式會給你這種效果。 – David
@paulvs看到我上面添加的代碼 - 我如何鏈接故事板視圖來替換我現在使用的'collectionView' –