Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

There is a possibility to add images (to be exact: icons or symbols) to the buttons of a UIActionSheet (or a UIAlertView) without loading image files or fiddling around with (sub)views. In these classes buttons are specified by their titles, which are strings. So it is obvious to use symbols, which one can specify also … Read more

UIImageView missing images in Launch Screen on device

Turn it off and then on again. Seriously, restart the device — that’s what fixed it for me. Here’s what didn’t work: Cleaning DerivedData. Cleaning the project. Uninstalling the app from the device. Restarting Xcode. Restarting the computer. Older observations: Just like the others, it: Works fine in the Simulator Used to work on the … Read more

How to round corners of UIImage with Hexagon mask

You can define a path that is a hexagon with rounded corners (defining that path manually) and then apply that as the mask and border sublayer: CGFloat lineWidth = 5.0; UIBezierPath *path = [UIBezierPath polygonInRect:self.imageView.bounds sides:6 lineWidth:lineWidth cornerRadius:30]; // mask for the image view CAShapeLayer *mask = [CAShapeLayer layer]; mask.path = path.CGPath; mask.lineWidth = lineWidth; … Read more

How to resize an image in iOS? [duplicate]

Try to implement the code below. It may be helpful for you: CGRect rect = CGRectMake(0,0,75,75); UIGraphicsBeginImageContext( rect.size ); [yourCurrentOriginalImage drawInRect:rect]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

How to crop the UIImage?

Try something like this: CGImageRef imageRef = CGImageCreateWithImageInRect([largeImage CGImage], cropRect); image = [UIImage imageWithCGImage:imageRef]; CGImageRelease(imageRef); Note: cropRect is smaller rectangle with middle part of the image…

How to display a base64 image within a UIImageView?

You don’t have to encode it. Simply make a NSUrl, it knows the “data:”-url. NSURL *url = [NSURL URLWithString:base64String]; NSData *imageData = [NSData dataWithContentsOfURL:url]; UIImage *ret = [UIImage imageWithData:imageData]; As mentioned in the comments, you have to make sure that you prepend your data with data:image/png;base64, or else your base64 data is useless.

add UIImage in CALayer

This is a general answer for the sake of future viewers. It is based on the question title rather than the details of the original question. How to add a UIImage to a CALayer You can add an image to a view’s layer simply by using its contents property: myView.layer.contents = UIImage(named: “star”)?.cgImage Note that … Read more

How can I color a UIImage in Swift?

Swift 4 and 5 extension UIImageView { func setImageColor(color: UIColor) { let templateImage = self.image?.withRenderingMode(.alwaysTemplate) self.image = templateImage self.tintColor = color } } Call like this: let imageView = UIImageView(image: UIImage(named: “your_image_name”)) imageView.setImageColor(color: UIColor.purple) Alternativ For Swift 3, 4 or 5 extension UIImage { func maskWithColor(color: UIColor) -> UIImage? { let maskImage = cgImage! let … Read more

tech