import
UIKit
class
ViewController
:
UIViewController
{
override
func
viewDidLoad() {
super
.viewDidLoad()
var
redView:
UIView
=
UIView
(frame:
CGRectMake
(20,20,280,400))
redView.backgroundColor =
UIColor
.redColor()
self
.view.insertSubview(redView, atIndex: 0)
var
blueView:
UIView
=
UIView
(frame:
CGRectMake
(20,20,280,400))
blueView.backgroundColor =
UIColor
.blueColor()
self
.view.insertSubview(blueView, atIndex: 1)
}
override
func
touchesBegan(touches:
Set
<
NSObject
>, withEvent event:
UIEvent
) {
var
transition =
CATransition
()
transition.duration = 3.0
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromLeft
self
.view.exchangeSubviewAtIndex(1, withSubviewAtIndex: 0)
self
.view.layer.addAnimation(transition, forKey:
nil
)
}
override
func
didReceiveMemoryWarning() {
super
.didReceiveMemoryWarning()
}
}
请发表评论