QQ侧滑实现架构:
需要建立以下几个ViewController:1.XQBaseViewController 2.LeftViewController3.RightViewController4.ContentViewController(中间显示的主要内容)5.SliderViewController(用于控制侧滑动画,控制左右侧栏的显示和隐藏)
1 import UIKit 2 class SliderViewController: UIViewController { 3 4 var mainContentView:UIView! 5 var leftSideView:UIView! 6 var rightSideView:UIView! 7 8 override func viewDidLoad() { 9 super.viewDidLoad();10 initSubViews()11 // showLeftViewController()12 }13 //在self.View上添加左中右三个视图14 func initSubViews()15 {16 let viewRect=self.view.bounds 17 rightSideView=UIView(frame:viewRect)18 rightSideView.backgroundColor=UIColor.blueColor()19 self.view.addSubview(rightSideView)20 leftSideView=UIView(frame:viewRect)21 leftSideView.backgroundColor=UIColor.yellowColor()22 self.view.addSubview(leftSideView)23 mainContentView=UIView(frame:viewRect)24 mainContentView.backgroundColor=UIColor.redColor()25 self.view.addSubview(mainContentView)26 }27 28 //显示左侧Controller29 func showLeftViewController()30 {31 let translateX:CGFloat=20032 let transcale:CGFloat=0.8533 var transT:CGAffineTransform=CGAffineTransformMakeTranslation(translateX, 0)34 var scaleT:CGAffineTransform=CGAffineTransformMakeScale(transcale, transcale)35 var conT:CGAffineTransform=CGAffineTransformConcat(transT, scaleT)36 UIView.animateWithDuration(0.8, animations: { () -> Void in37 self.mainContentView.transform=conT38 })39 }40 }
本文出自:
小鸟天空博客:转载请注明来源。