• 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: UI to allow user to scale and crop image within a circle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UI to allow user to scale and crop image within a circle


  • Subject: Re: UI to allow user to scale and crop image within a circle
  • From: Graham Cox <email@hidden>
  • Date: Thu, 25 Feb 2016 08:44:04 +1100

> On 24 Feb 2016, at 11:08 PM, Charles Jenkins <email@hidden> wrote:
>
> My guess is, you do this by adding a mask layer; but you probably don’t redraw the mask in drawRect(), hm? It should never need to be refreshed unless the bounds change.


Can you not just use a clipping path? They’re usually much easier to set up especially for simple cases like this than a mask layer.

e.g. the simplest way I can think of drawing this is a) draw your image at the correct size and position, b) form a clipping path from the bounds rect plus the desired circle, setting the winding rule if necessary so that the path includes all of the area of your view EXCEPT the circle. c) paint over the entire view in a solid colour (black I think you said). The clipping path ensures that you won’t paint over the circular aperture that shows the image.

> Assuming I can figure out how to make a mask layer, what is the correct way to monitor for a bounds change in order to recreate the mask?


Override -setFrame:, call super then do what you need to do.

However, if you use a clipping path, you can just create this on the fly as part of -drawRect: and so it’ll always be correct, and you won’t need to do this. There’s no reason to cache this path unless it’s really complex and expensive. Hint: it’s not, it’s a circle.

—Graham



_______________________________________________

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


  • Follow-Ups:
    • Re: UI to allow user to scale and crop image within a circle
      • From: Quincey Morris <email@hidden>
    • Re: UI to allow user to scale and crop image within a circle
      • From: David Duncan <email@hidden>
References: 
 >UI to allow user to scale and crop image within a circle (From: Charles Jenkins <email@hidden>)
 >Re: UI to allow user to scale and crop image within a circle (From: Charles Jenkins <email@hidden>)
 >Re: UI to allow user to scale and crop image within a circle (From: Quincey Morris <email@hidden>)
 >Re: UI to allow user to scale and crop image within a circle (From: Charles Jenkins <email@hidden>)
 >Re: UI to allow user to scale and crop image within a circle (From: Quincey Morris <email@hidden>)
 >Re: UI to allow user to scale and crop image within a circle (From: Charles Jenkins <email@hidden>)
 >Re: UI to allow user to scale and crop image within a circle (From: Quincey Morris <email@hidden>)
 >Re: UI to allow user to scale and crop image within a circle (From: David Duncan <email@hidden>)
 >Re: UI to allow user to scale and crop image within a circle (From: Charles Jenkins <email@hidden>)

  • Prev by Date: Re: When to remove Gesture Recognizers
  • Next by Date: Re: UI to allow user to scale and crop image within a circle
  • Previous by thread: Re: UI to allow user to scale and crop image within a circle
  • Next by thread: Re: UI to allow user to scale and crop image within a circle
  • Index(es):
    • Date
    • Thread