James
James

Reputation: 201

UIImageView over another

I have two UIImageView's one that will contain my product image, and one that I had a graphic designer make that is this:

enter image description here

Is there anyway I could have that image overlay another UIImageView to give it those effects? My designer stated I could put any smart object in there where the green is, but I assume he was referring to Photoshop, as he doesn't develop and I've only heard that term really used in Photoshop. Can this be achieved with XCode?

enter image description here

Upvotes: 0

Views: 214

Answers (1)

Jim Tierney
Jim Tierney

Reputation: 4105

Assuming the top designer image has a transparency, place your UIImageView behind this image, setting the width and height matching the diameter of the designed circle frame image.

Your UIImageView connected from your storyboard or xib to your class file

@property (weak, nonatomic) IBOutlet UIImageView *photoImage;

Then within your viewDidLoad add the following code which will mask the object so it is cropped to a circle image.

-(void)viewDidLoad{

    [super viewDidLoad];

    self.photoImage.layer.cornerRadius = self.photoImage.frame.size.width/2;
    self.photoImage.layer.masksToBounds = YES;

}

I hope this helps

Upvotes: 1

Related Questions