Skip to content

Commit

Permalink
fixed 219
Browse files Browse the repository at this point in the history
  • Loading branch information
tilltue committed Sep 24, 2019
1 parent 00b0e04 commit a635c4f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
14 changes: 14 additions & 0 deletions TLPhotoPicker/Classes/TLAlbumPopView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ open class TLAlbumPopView: UIView,PopupViewProtocol {
// print("deinit TLAlbumPopView")
}

open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if
#available(iOS 13.0, *),
let userInterfaceStyle = previousTraitCollection?.userInterfaceStyle
{
if userInterfaceStyle.rawValue == 2 {
self.popupView.backgroundColor = UIColor.systemBackground
}else {
self.popupView.backgroundColor = UIColor.white
}
}
}

override open func awakeFromNib() {
super.awakeFromNib()
self.popupView.layer.cornerRadius = 5.0
Expand Down
12 changes: 12 additions & 0 deletions TLPhotoPicker/Classes/TLCollectionTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ open class TLCollectionTableViewCell: UITableViewCell {
self.thumbImageView.accessibilityIgnoresInvertColors = true
}
}

open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if #available(iOS 12.0, *) {
let userInterfaceStyle = traitCollection.userInterfaceStyle
if userInterfaceStyle.rawValue == 2 {
self.contentView.backgroundColor = .black
}else {
self.contentView.backgroundColor = .white
}
}
}
}
34 changes: 34 additions & 0 deletions TLPhotoPicker/Classes/TLPhotosPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ open class TLPhotosPickerViewController: UIViewController {
return self.configure.supportedInterfaceOrientations
}

open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
if #available(iOS 13.0, *) {
let userInterfaceStyle = traitCollection.userInterfaceStyle
let image = TLBundle.podBundleImage(named: "pop_arrow")
if userInterfaceStyle.rawValue == 2 {
self.popArrowImageView.image = image?.colorMask(color: .systemBackground)
self.view.backgroundColor = .black
self.collectionView.backgroundColor = .black
}else {
self.popArrowImageView.image = image?.colorMask(color: .white)
self.view.backgroundColor = .white
self.collectionView.backgroundColor = .white
}
}
}

override open func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
self.stopPlay()
Expand Down Expand Up @@ -1118,3 +1135,20 @@ extension Array where Element == PopupConfigure {
return result
}
}

extension UIImage {
public func colorMask(color:UIColor) -> UIImage {
var result: UIImage?
let rect = CGRect(x:0, y:0, width:size.width, height:size.height)
UIGraphicsBeginImageContextWithOptions(rect.size, false, scale)
if let c = UIGraphicsGetCurrentContext() {
self.draw(in: rect)
c.setFillColor(color.cgColor)
c.setBlendMode(.sourceAtop)
c.fill(rect)
result = UIGraphicsGetImageFromCurrentImageContext()
}
UIGraphicsEndImageContext()
return result ?? self
}
}

0 comments on commit a635c4f

Please sign in to comment.