Animate chevron rotation
This commit is contained in:
parent
25fa5e0167
commit
3464fbfc7f
|
@ -48,12 +48,12 @@ struct AppAssets {
|
||||||
return UIImage(systemName: "circle")!
|
return UIImage(systemName: "circle")!
|
||||||
}()
|
}()
|
||||||
|
|
||||||
static var chevronDownImage: UIImage = {
|
static var chevronSmallImage: UIImage = {
|
||||||
return UIImage(systemName: "chevron.down")!
|
return UIImage(named: "chevronSmall")!
|
||||||
}()
|
}()
|
||||||
|
|
||||||
static var chevronRightImage: UIImage = {
|
static var chevronBaseImage: UIImage = {
|
||||||
return UIImage(systemName: "chevron.right")!
|
return UIImage(named: "chevronBase")!
|
||||||
}()
|
}()
|
||||||
|
|
||||||
static var copyImage: UIImage = {
|
static var copyImage: UIImage = {
|
||||||
|
|
|
@ -152,15 +152,18 @@ private extension MasterFeedTableViewCell {
|
||||||
func addDisclosureView() {
|
func addDisclosureView() {
|
||||||
disclosureButton = NonIntrinsicButton(type: .roundedRect)
|
disclosureButton = NonIntrinsicButton(type: .roundedRect)
|
||||||
disclosureButton!.addTarget(self, action: #selector(buttonPressed(_:)), for: UIControl.Event.touchUpInside)
|
disclosureButton!.addTarget(self, action: #selector(buttonPressed(_:)), for: UIControl.Event.touchUpInside)
|
||||||
|
disclosureButton?.setImage(AppAssets.chevronBaseImage, for: .normal)
|
||||||
updateDisclosureImage()
|
updateDisclosureImage()
|
||||||
addSubviewAtInit(disclosureButton!)
|
addSubviewAtInit(disclosureButton!)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateDisclosureImage() {
|
func updateDisclosureImage() {
|
||||||
if disclosureExpanded {
|
UIView.animate(withDuration: 0.3) {
|
||||||
disclosureButton?.setImage(AppAssets.chevronDownImage, for: .normal)
|
if self.disclosureExpanded {
|
||||||
} else {
|
self.disclosureButton?.imageView?.transform = CGAffineTransform(rotationAngle: 1.570796)
|
||||||
disclosureButton?.setImage(AppAssets.chevronRightImage, for: .normal)
|
} else {
|
||||||
|
self.disclosureButton?.imageView?.transform = CGAffineTransform(rotationAngle: 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,8 @@ class MasterFeedTableViewSectionHeader: UITableViewHeaderFooterView {
|
||||||
private let unreadCountView = MasterFeedUnreadCountView(frame: CGRect.zero)
|
private let unreadCountView = MasterFeedUnreadCountView(frame: CGRect.zero)
|
||||||
private var disclosureView: UIImageView = {
|
private var disclosureView: UIImageView = {
|
||||||
let iView = NonIntrinsicImageView()
|
let iView = NonIntrinsicImageView()
|
||||||
|
iView.tintColor = UIColor.tertiaryLabel
|
||||||
|
iView.image = AppAssets.chevronSmallImage
|
||||||
iView.contentMode = .center
|
iView.contentMode = .center
|
||||||
return iView
|
return iView
|
||||||
}()
|
}()
|
||||||
|
@ -131,11 +133,12 @@ private extension MasterFeedTableViewSectionHeader {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateDisclosureImage() {
|
func updateDisclosureImage() {
|
||||||
disclosureView.tintColor = UIColor.tertiaryLabel
|
UIView.animate(withDuration: 0.3) {
|
||||||
if disclosureExpanded {
|
if self.disclosureExpanded {
|
||||||
disclosureView.image = AppAssets.chevronDownImage
|
self.disclosureView.transform = CGAffineTransform(rotationAngle: 1.570796)
|
||||||
} else {
|
} else {
|
||||||
disclosureView.image = AppAssets.chevronRightImage
|
self.disclosureView.transform = CGAffineTransform(rotationAngle: 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "chevron-base.pdf"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "template"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "chevron-small.pdf"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "template"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in New Issue