Tag: mask

How to implement highlighting on UIImage like UIButton does when tapped?

I need to replicate the effect that the UIButton does on an image when tapped, the highlighting. See: The original PNG is a square with alpha background. When I set it as UIButton’s image it automatically apply an effect on the non-alpha pixels of the image. How to do this effect?

How to mask a UIScrollView?

I currently have an image mask I want to use to mask a UIScrollView. The scrollview holds 1 UIImageView. Here is what I do at the moment in viewdidload: CALayer *mask = [CALayer layer]; mask.contents = (id)[UIImage imageNamed:@”ScrollMask.png”].CGImage; mask.frame = CGRectMake(0, 0, 512, 384); [Scroll1.layer setMask:mask]; This works to some degree. It masks the ImageView […]

Swift – Border Inside Masked Image

I have a masked image that’s utilized by a UIBezierPath() and I’d like to have a border around the masked portion rather than the original image. I’ve come this close in my (countless number) attempt through trial and error and, tirelessly, given up. Any easier way to do this? This is how far I’ve come […]

Using an UIView as a Mask in another UIView on Swift

Can someone please help me with something? I have done a lot of research and found nothing. It’s about masking. I am developing an App on xCode with Swift. My screen has an Image of an animal (outlet “backImage”), over this image I have a view (outlet “coverView”), color black, which covers all the screen. […]

Swift: Mask Alignment + Auto-Layout Constraints

I have this PNG file, which I’d like to use as a mask for a UIView. The view must be: 20 pixels/points in from each side A perfect square Centered vertically I set the following constraints to accomplish this: However, it seems these constraints don’t play well with masks. When these constraints and the mask […]

Drawing UIImage mask with GestureRecognizer

I’m trying to combine 2 mechanisms and I’m not getting very far on finding a solution. This is what I want to be able to do :- I have a routine that allows me to draw a mask on a UIImage layer which has a 2nd UIImage below which contains the image I am drawing […]

Reverse a CALayer mask

I am trying to use a CALayer with an image as contents for masking a UIView. For the mask I have complex png image. If I apply the image as a view.layer.mask I get the opposite behaviour of what I want. Is there a way to reverse the CAlayer? Here is my code: layerMask = […]

Masking UIView/UIImageView to cutout transparent text

How can I mask an UIView or UIImageView so that a text is cutout from it? I googled a lot and it seems that many people struggled the same. Most irritating I always tried to invert the alpha of a snapshotted view to get the result. What I want looks like this:

How do I (successfully) set a maskView to a UIView?

I’m making a camera-based app and would like to make a frosted overlay on the camera preview, with a rounded rectangle cut out from the frosted view. I’ve been trying to achieve this with the maskLayer of UIView, introduced with iOS 8 and have been wildly unsuccessful. Here’s what my code currently looks like: // […]

UIImage by selecting part of another UIImage

I have an UIImage and a CGPoint which tells me in what direction I should move it to create another image. The background can be anything. Give the initial UIImage how I can create the new one? What is the most efficient way of doing it? Here is what I’m doing: int originalWidth = image.size.width; […]