-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHighlightedStateView.swift
39 lines (32 loc) · 1014 Bytes
/
HighlightedStateView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// HighlightedStateView.swift
// SmartStream
//
// Created by Jerry on 3/22/16.
// Copyright © 2016 SmartStream. All rights reserved.
//
import UIKit
class HighlightedStateView: UIView {
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
// Drawing code
}
*/
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
UIView.animateWithDuration(0.3, animations: { () -> Void in
self.layer.opacity = 0.3
})
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
UIView.animateWithDuration(0.3, animations: { () -> Void in
self.layer.opacity = 1
})
}
override func didMoveToWindow() {
UIView.animateWithDuration(0.3, animations: { () -> Void in
self.layer.opacity = 1
})
}
}