Skip to content

Instantly share code, notes, and snippets.

@hcn1519
Created June 3, 2019 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hcn1519/db11601282bd85e72e0122253c529cb9 to your computer and use it in GitHub Desktop.
Save hcn1519/db11601282bd85e72e0122253c529cb9 to your computer and use it in GitHub Desktop.
/ back 버튼 여백 적용 메소드
extension UIImage {
func imageWithInsets(insets: UIEdgeInsets) -> UIImage {
UIGraphicsBeginImageContextWithOptions(
CGSize(width: self.size.width + insets.left + insets.right,
height: self.size.height + insets.top + insets.bottom),
false, self.scale)
guard UIGraphicsGetCurrentContext() != nil else { return UIImage() }
let origin = CGPoint(x: insets.left, y: insets.top)
self.draw(at: origin)
guard let imageWithInsets = UIGraphicsGetImageFromCurrentImageContext() else { return UIImage() }
UIGraphicsEndImageContext()
return imageWithInsets
}
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// back Button
let backImage = #imageLiteral(resourceName: "left_white").imageWithInsets(insets: UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 0))
let navbarAppearace = UINavigationBar.appearance()
navbarAppearace.backIndicatorTransitionMaskImage = backImage
navbarAppearace.backIndicatorImage = backImage
navbarAppearace.barStyle = .black
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment