daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Nov 18th, 2017 52 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. extension UIImage {
  2.  
  3.     static func imageByMergingImages(topImage: UIImage, bottomImage: UIImage, scaleForTop: CGFloat = 1.0) -> UIImage {
  4.         let size = bottomImage.size
  5.         let container = CGRect(x: 0, y: 0, width: size.width, height: size.height)
  6.         UIGraphicsBeginImageContextWithOptions(size, false, 2.0)
  7.         UIGraphicsGetCurrentContext()!.interpolationQuality = .high
  8.         bottomImage.draw(in: container)
  9.  
  10.         let topWidth = size.width / scaleForTop
  11.         let topHeight = size.height / scaleForTop
  12.         let topX = (size.width / 2.0) - (topWidth / 2.0)
  13.         let topY = (size.height / 2.0) - (topHeight / 2.0)
  14.  
  15.         topImage.draw(in: CGRect(x: topX, y: topY, width: topWidth, height: topHeight), blendMode: .normal, alpha: 1.0)
  16.  
  17.         return UIGraphicsGetImageFromCurrentImageContext()!
  18.     }
  19.  
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top