Re: Trying to create a circular button with image, but the image wasn't clipped automatically
Re: Trying to create a circular button with image, but the image wasn't clipped automatically
- Subject: Re: Trying to create a circular button with image, but the image wasn't clipped automatically
- From: Jonathan Hull <email@hidden>
- Date: Sat, 07 Feb 2015 22:52:00 -0800
You need to set the layer’s -maskToBounds: property to YES to clip.
Thanks,
Jon
> On Feb 7, 2015, at 10:38 PM, Aaron Lewis <email@hidden> wrote:
>
> Hi,
>
> I'm trying to create a circular button, with an rectangular image:
>
> self.button.layer.borderColor = [UIColor blackColor].CGColor;
> self.button.layer.borderWidth = 5;
> self.button.layer.cornerRadius = self.button.bounds.size.width / 2.0;
> [self.button setBackgroundImage: [UIImage
> imageNamed:@"avatar.jpeg"] forState:UIControlStateNormal];
>
> But the framework doesn't seem to "clip" the rectangular image into a
> circular one.
> All extra parts are displayed on screen.
>
> Did I get this wrong? Am I expected to use only circular images?
>
>
> --
> Best Regards,
> Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/
> Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden