Skip to content

Commit

Permalink
Merge pull request #16 from yurnery/master
Browse files Browse the repository at this point in the history
增加 title  属性
  • Loading branch information
CodeEagle authored May 2, 2017
2 parents 63d5650 + 42de20a commit 62a4d6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Example/SSImageBrowser/TableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ class TableViewController: UITableViewController {
browser.usePopAnimation = true
// browser.displayDownloadButton = false
browser.alwysShowDownloadButton = true
// let att = NSAttributedString(string: "downL", attributes: [NSForegroundColorAttributeName: UIColor.red, NSFontAttributeName: UIFont.systemFont(ofSize: 12)])
// browser.downLoadButtonTitle = att
browser.downLoadButtonFrame = CGRect(x: 200, y: 600, width: 50, height: 44)
browser.scaleImage = buttonSender.currentImage
if (buttonSender.tag == 102) {
browser.useWhiteBackgroundColor = true
Expand Down
19 changes: 15 additions & 4 deletions Source/SSImageBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ open class SSImageBrowser: UIViewController {
open lazy var displayDoneButton = true
open lazy var displayDownloadButton = true
open lazy var alwysShowDownloadButton = false
open var downLoadButtonTitle : NSAttributedString?
open var downLoadButtonSelectedTitle: NSAttributedString?

open lazy var useWhiteBackgroundColor = false
open lazy var arrowButtonsChangePhotosAnimated = true
Expand Down Expand Up @@ -93,7 +95,7 @@ open class SSImageBrowser: UIViewController {
fileprivate var hideTask: CancelableTask!
fileprivate var _completion: (() -> ())?

fileprivate var _isUserTap : Bool = false
fileprivate var _isUseTap : Bool = false

fileprivate func areControlsHidden() -> Bool {
if let t = toolbar {
Expand Down Expand Up @@ -173,7 +175,7 @@ extension SSImageBrowser {
photos = aPhotos
senderViewForAnimation = view
performPresentAnimation()
_isUserTap = useTapToClose
_isUseTap = useTapToClose
}
}
// MARK: - Life Cycle
Expand Down Expand Up @@ -305,6 +307,15 @@ extension SSImageBrowser {
downLoadButton.setBackgroundImage(downLoadButtonImage, for: .normal)
downLoadButton.contentMode = .scaleAspectFit
}

if downLoadButtonTitle != nil {
downLoadButton.setAttributedTitle(downLoadButtonTitle, for: .normal)
downLoadButton.sizeToFit()
}
if downLoadButtonSelectedTitle != nil{
downLoadButton.setAttributedTitle(downLoadButtonSelectedTitle, for: .selected)
}

}

open override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -975,7 +986,7 @@ extension SSImageBrowser {
view.addGestureRecognizer(panGesture)
}

if _isUserTap{
if _isUseTap{
let tap = UITapGestureRecognizer(target: self, action: #selector(SSImageBrowser.tapGesture(_:)))
view.addGestureRecognizer(tap)
}
Expand Down Expand Up @@ -1051,7 +1062,7 @@ extension SSImageBrowser {
let screenBound = view.bounds
let screenWidth = screenBound.size.width
let screenHeight = screenBound.size.height
return CGRect(x: (screenWidth - 26) / 2.0, y: screenHeight - 120, width: 36, height: 36)
return CGRect(x: (screenWidth - 36) / 2.0, y: screenHeight - 120, width: 36, height: 36)
}

fileprivate func frameForCaptionView(_ captionView: SSCaptionView, atIndex index: Int) -> CGRect {
Expand Down

0 comments on commit 62a4d6f

Please sign in to comment.