在 view 內(nèi)部初始化 cyan顏色的 subview,其 bottom 和 父視圖的 bottom 一致
對應(yīng)的 vc 中 進行動畫處理
weak var weakself = self
UIView.animate(withDuration: 0.5, animations: {
weakself?.search_gist_view.frame = CGRect.init(x: 0, y: 40, width: SCREEN_W, height: button.isSelected ? 144 : 44)
})
此時動畫效果如下:

子視圖不隨父視圖一起動畫
雖然可設(shè)置 父視圖.layer.masksToBounds = true
設(shè)置后 彈出時候的 動畫正常,收回的時候,子視圖依舊先消失,然后父視圖在進行動畫
解決: 使用可以設(shè)置 UIViewAnimationOptions 的動畫開啟方式
// public static var layoutSubviews: UIViewAnimationOptions { get } 動畫過程中使子視圖和父視圖一致
weak var weakself = self
UIView.animate(withDuration: 0.5, delay: 0, options: .layoutSubviews, animations: {
weakself?.search_gist_view.frame = CGRect.init(x: 0, y: 40, width: SCREEN_W, height: button.isSelected ? 144 : 44)
}, completion: { (is_finished) in
})
效果:
