Merge pull request #138 from rp4rk/feature/resize-buttons

Resizing for Buttons
This commit is contained in:
keishi suzuki 2016-09-06 10:48:24 +09:00 committed by GitHub
commit d5b42c8b47
2 changed files with 29 additions and 9 deletions

View File

@ -34,8 +34,15 @@ class SKButton: UIButton {
inBundle: bundle, compatibleWithTraitCollection: nil) ?? UIImage()
setImage(image, forState: .Normal)
}
func updateFrame() {}
func updateFrame() { }
func setFrameSize(size: CGSize) {
let newRect = CGRect(x: margin, y: buttonTopOffset, width: size.width, height: size.height)
self.frame = newRect
showFrame = newRect
hideFrame = CGRect(x: margin, y: -20, width: size.width, height: size.height)
}
}
class SKCloseButton: SKButton {
@ -64,12 +71,17 @@ class SKDeleteButton: SKButton {
override init(frame: CGRect) {
super.init(frame: frame)
setup(imageName)
showFrame = CGRect(x: SKMesurement.screenWidth - size.width, y: buttonTopOffset,
width: size.width, height: size.height)
hideFrame = CGRect(x: SKMesurement.screenWidth - size.width, y: -20,
width: size.width, height: size.height)
showFrame = CGRect(x: SKMesurement.screenWidth - size.width, y: buttonTopOffset, width: size.width, height: size.height)
hideFrame = CGRect(x: SKMesurement.screenWidth - size.width, y: -20, width: size.width, height: size.height)
}
override func updateFrame() {
}
override func setFrameSize(size: CGSize) {
let newRect = CGRect(x: SKMesurement.screenWidth - size.width, y: buttonTopOffset, width: size.width, height: size.height)
self.frame = newRect
showFrame = newRect
hideFrame = CGRect(x: SKMesurement.screenWidth - size.width, y: -20, width: size.width, height: size.height)
}
}

View File

@ -222,18 +222,26 @@ public class SKPhotoBrowser: UIViewController {
// MARK: - Public Function For Customizing Buttons
public extension SKPhotoBrowser {
func updateCloseButton(image: UIImage) {
func updateCloseButton(image: UIImage, size: CGSize? = nil) {
if closeButton == nil {
configureCloseButton()
}
closeButton.setImage(image, forState: .Normal)
}
func updateDeleteButton(image: UIImage) {
if let size = size {
closeButton.setFrameSize(size)
}
}
func updateDeleteButton(image: UIImage, size: CGSize? = nil) {
if deleteButton == nil {
configureDeleteButton()
}
deleteButton.setImage(image, forState: .Normal)
if let size = size {
deleteButton.setFrameSize(size)
}
}
}