• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trying to create a circular button with image, but the image wasn't clipped automatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Trying to create a circular button with image, but the image wasn't clipped automatically (From: Aaron Lewis <email@hidden>)

  • Prev by Date: What UIControl could this be?
  • Next by Date: Re: Identify all open files of current OS X process
  • Previous by thread: Trying to create a circular button with image, but the image wasn't clipped automatically
  • Next by thread: What UIControl could this be?
  • Index(es):
    • Date
    • Thread