Created
January 18, 2021 14:51
-
-
Save mohsinbmwm3/b5457959b4b370eaf20571cc9ae8272e to your computer and use it in GitHub Desktop.
Some UIImage extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIImage { | |
func resize(height: CGFloat, width: CGFloat) -> UIImage { | |
UIGraphicsBeginImageContext(CGSize(width: width, height: height)) | |
draw(in: CGRect(x: 0, y: 0, width: width, height: height)) | |
let resizedImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return resizedImage! | |
} | |
static func defaultProfilePicture() -> UIImage { | |
// This can be useful when user dont have a profile picture. | |
return UIImage(imageLiteralResourceName: "YourDefaultProfilePictureImageAssetName") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment