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

2016-02-24 Thread David Duncan

> On Feb 24, 2016, at 3:47 PM, Quincey Morris 
>  wrote:
> 
> On Feb 24, 2016, at 13:44 , Graham Cox  > wrote:
>> 
>> 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
> 
> I don’t recall Charles’s drawing code exactly, but I think this is just part 
> of the solution. It’ll always be correct for the part of the view being 
> drawn, but there’s no guarantee that the whole view will be redrawn if the 
> relationship between the bounds origin and the circle changes. I think 
> Charles still needs something to force redrawing of the whole view when the 
> view geometry changes.

By default -setNeedsDisplay will dirty the entire view for redraw. 
-setNeedsDisplayInRect: can be used for partial updates, but typically you will 
call that directly. If you always draw inside of the whole bounds of the view 
however, you are generally insulated from origin changes (as either 
setNeedsDisplay method should do the right thing in these circumstances).

> 
> Of course, if the view geometry never changes, or the relationship of the 
> circle to the bounds origin never changes, then I think the forced redrawing 
> isn’t necessary.
> 

--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-24 Thread Quincey Morris
On Feb 24, 2016, at 13:44 , Graham Cox  wrote:
> 
> 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

I don’t recall Charles’s drawing code exactly, but I think this is just part of 
the solution. It’ll always be correct for the part of the view being drawn, but 
there’s no guarantee that the whole view will be redrawn if the relationship 
between the bounds origin and the circle changes. I think Charles still needs 
something to force redrawing of the whole view when the view geometry changes.

Of course, if the view geometry never changes, or the relationship of the 
circle to the bounds origin never changes, then I think the forced redrawing 
isn’t necessary.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-24 Thread David Duncan

> On Feb 24, 2016, at 1:44 PM, Graham Cox  wrote:
> 
> 
>> On 24 Feb 2016, at 11:08 PM, Charles Jenkins  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.

-layoutSubviews would be better, as in general if you need to override 
-setFrame: for something, you also need to override -setCenter: and 
-setBounds:. If you need to ensure animation works, you can call 
-layoutIfNeeded inside of your animation block.

But since your drawing something, a clipping view isn’t necessary – you can 
just clip your drawing.

> 
> 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
> 
> 

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-24 Thread Graham Cox

> On 24 Feb 2016, at 11:08 PM, Charles Jenkins  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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-24 Thread David Duncan

> On Feb 24, 2016, at 4:08 AM, Charles Jenkins  wrote:
> 
> Good tip! Thanks, Dave and Quincey. I was pretty sure the problem was 
> something embarrassingly basic.
> 
> The next step is to redesign the CircleOverlayView to fill its view with 
> black except for the center of the circle. I already learned that filling the 
> view with black and then filling the circle with clearColor() doesn’t work! 
> 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.
> 
> 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?

You can’t fill with clear color with normal blending because clear color has 0 
alpha. You can however fill it with the copy blend mode.

> 
> -- 
> 
> Charles
> 
> On February 24, 2016 at 03:16:00, David Duncan (david.dun...@apple.com 
> ) wrote:
> 
>> 
>> > On Feb 23, 2016, at 7:17 PM, Quincey Morris 
>> >  wrote: 
>> >  
>> > On Feb 23, 2016, at 18:50 , Charles Jenkins  wrote: 
>> >>  
>> >> I draw based on the overlay view’s frame, NOT based on the rect that gets 
>> >> passed in to drawRect(). I must not understand what that parameter is 
>> >> for. 
>> >  
>> > From the UIView documentation for ‘drawRect’: 
>> >  
>> >> The portion of the view’s bounds that needs to be updated. The first time 
>> >> your view is drawn, this rectangle is typically the entire visible bounds 
>> >> of your view. However, during subsequent drawing operations, the 
>> >> rectangle may specify only part of your view. 
>> >  
>> >  
>> > So, yes, your code is right now. :) 
>> >  
>> 
>> Its almost right – drawing should be done based on the bounds not the frame 
>> (this will be an issue if you either use the frame.origin or if you 
>> transform the view). 
>> 
>> > ___ 
>> >  
>> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 
>> >  
>> > 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: 
>> > https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com 
>> >  
>> > This email sent to david.dun...@apple.com 
>> 
>> -- 
>> David Duncan

--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-24 Thread Charles Jenkins
Good tip! Thanks, Dave and Quincey. I was pretty sure the problem was something 
embarrassingly basic.

The next step is to redesign the CircleOverlayView to fill its view with black 
except for the center of the circle. I already learned that filling the view 
with black and then filling the circle with clearColor() doesn’t work! 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.

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?

-- 

Charles

On February 24, 2016 at 03:16:00, David Duncan (david.dun...@apple.com) wrote:


> On Feb 23, 2016, at 7:17 PM, Quincey Morris 
>  wrote:  
>  
> On Feb 23, 2016, at 18:50 , Charles Jenkins  wrote:  
>>  
>> I draw based on the overlay view’s frame, NOT based on the rect that gets 
>> passed in to drawRect(). I must not understand what that parameter is for.  
>  
> From the UIView documentation for ‘drawRect’:  
>  
>> The portion of the view’s bounds that needs to be updated. The first time 
>> your view is drawn, this rectangle is typically the entire visible bounds of 
>> your view. However, during subsequent drawing operations, the rectangle may 
>> specify only part of your view.  
>  
>  
> So, yes, your code is right now. :)  
>  

Its almost right – drawing should be done based on the bounds not the frame 
(this will be an issue if you either use the frame.origin or if you transform 
the view).  

> ___  
>  
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)  
>  
> 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:  
> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com  
>  
> This email sent to david.dun...@apple.com  

--  
David Duncan  

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-24 Thread David Duncan

> On Feb 23, 2016, at 7:17 PM, Quincey Morris 
>  wrote:
> 
> On Feb 23, 2016, at 18:50 , Charles Jenkins  wrote:
>> 
>> I draw based on the overlay view’s frame, NOT based on the rect that gets 
>> passed in to drawRect(). I must not understand what that parameter is for.
> 
> From the UIView documentation for ‘drawRect’:
> 
>> The portion of the view’s bounds that needs to be updated. The first time 
>> your view is drawn, this rectangle is typically the entire visible bounds of 
>> your view. However, during subsequent drawing operations, the rectangle may 
>> specify only part of your view.
> 
> 
> So, yes, your code is right now. :)
> 

Its almost right – drawing should be done based on the bounds not the frame 
(this will be an issue if you either use the frame.origin or if you transform 
the view).

> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-23 Thread Quincey Morris
On Feb 23, 2016, at 18:50 , Charles Jenkins  wrote:
> 
> I draw based on the overlay view’s frame, NOT based on the rect that gets 
> passed in to drawRect(). I must not understand what that parameter is for.

From the UIView documentation for ‘drawRect’:

> The portion of the view’s bounds that needs to be updated. The first time 
> your view is drawn, this rectangle is typically the entire visible bounds of 
> your view. However, during subsequent drawing operations, the rectangle may 
> specify only part of your view.


So, yes, your code is right now. :)

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-23 Thread Charles Jenkins
I might’ve solved this. My overlay view works now because I draw based on the 
overlay view’s frame, NOT based on the rect that gets passed in to drawRect(). 
I must not understand what that parameter is for.

I guess the pinning constraints were working all along, but I just couldn’t 
tell because my circle kept being drawn in the wrong place.

Does it look like I’m doing this the right way now, or am I heading for trouble 
by ignoring the parameter to drawRect()?

class CircleOverlayView: UIView {

  override init( frame: CGRect )
  {
    super.init( frame: frame )

    opaque = false
    userInteractionEnabled = false
    translatesAutoresizingMaskIntoConstraints = false
    
    backgroundColor = UIColor.clearColor()
  }

  required init?( coder: NSCoder )
  {
    super.init( coder: coder )
  }

  override func drawRect( rect: CGRect )
  {
    let w = frame.size.width
    let h = frame.size.height
    let d = min( w, h )

    let innerRect = CGRectMake( ( w - d ) / 2, ( h - d ) / 2, d, d )
    let innerPath = UIBezierPath( ovalInRect: innerRect )
    UIColor.redColor().setStroke()
    innerPath.lineWidth = 2
    innerPath.stroke()
  }

}

-- 

Charles

On February 23, 2016 at 3:49:28 PM, Quincey Morris 
(quinceymor...@rivergatesoftware.com) wrote:

On Feb 23, 2016, at 12:32 , Charles Jenkins  wrote:

This is the first time I’ve tried to inject an overlay view into the view 
hierarchy, so I’m probably doing it completely wrong or missing something very 
basic.

I’d suggest you go and watch the WWDC videos about advanced scroll view usage, 
starting with session 104 in 2011, then session 223 in 2012, session 217 in 
2013 and session 235 in 2014. Unfortunately, that’s where the series seems to 
have ended.

That’s a bit under 4 hours of video, but they’re incredibly well worth watching 
for anyone who’s interested in doing clever things with scroll views. Not only 
are they technically enlightening, but they are very, very entertaining.

There’s 5 minutes or so in one of these videos that will tell you how to solve 
your problem neatly. (Bu I don’t know *which* 5 minutes. Possibly the “moon 
over cityscape” section?) The rest is just for fun.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-23 Thread Quincey Morris
On Feb 23, 2016, at 12:32 , Charles Jenkins  wrote:
> 
> This is the first time I’ve tried to inject an overlay view into the view 
> hierarchy, so I’m probably doing it completely wrong or missing something 
> very basic.

I’d suggest you go and watch the WWDC videos about advanced scroll view usage, 
starting with session 104 in 2011, then session 223 in 2012, session 217 in 
2013 and session 235 in 2014. Unfortunately, that’s where the series seems to 
have ended.

That’s a bit under 4 hours of video, but they’re incredibly well worth watching 
for anyone who’s interested in doing clever things with scroll views. Not only 
are they technically enlightening, but they are very, very entertaining.

There’s 5 minutes or so in one of these videos that will tell you how to solve 
your problem neatly. (Bu I don’t know *which* 5 minutes. Possibly the “moon 
over cityscape” section?) The rest is just for fun.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-23 Thread Charles Jenkins
Jon:

Thanks for that advice. I’ll have a look!

Quincey:

I start with a screen in the storyboard and its default view I’ll call 
“superview.” Into the superview I toss a scrollview and a toolbar with Cancel 
and Crop buttons. I position them with autolayout and wire them up to my Swift 
view controller class.

In viewDidLoad(), I take an image previously selected by the user, create a 
UIImageView for it, then put that into the scrollview. The view controller 
instance sets itself to be the scrollview’s delegate, and when the scrollview 
asks, “what am I scrolling and sizing?” that UIImageView is what the call 
returns. When the user taps “Crop,” we notify the class that brought this view 
controller into existence, and it asks for the scaled and cropped portion of 
the image appearing in the scrollview. So far all this stuff seems to work 
perfectly.

The only thing I’m lacking is, I want to show a circle over the scrollview so 
that the user can see what portion of the image will be retained if we crop the 
image into a circle. The circle should aspect-fit over the scrollview’s 
viewport, but not be managed by the scrollview. The scrollview knows nothing 
about the circle. The circle’s just a layer hovering “above” the scrollview but 
not accepting touch events.

I’ve been trying to make the circle with an overlay UIImageView pinned so its 
frame is sized and positioned over the scrollview, but either (a) the overlay 
isn’t getting resized by autolayout, or (b) the circle artwork isn’t 
aspect-fitting inside the overlay view.

My approach may be completely wrong. This is the first time I’ve tried to 
inject an overlay view into the view hierarchy, so I’m probably doing it 
completely wrong or missing something very basic.

-- 

Charles

On February 23, 2016 at 12:51:59, Quincey Morris 
(quinceymor...@rivergatesoftware.com) wrote:

On Feb 23, 2016, at 04:28 , Charles Jenkins  wrote:

My scrollview containing an imageview seems to work just fine: I can scale and 
crop an image with no problem. But I’m having difficulty getting the desired 
“crop circle” to hover over the scrollview properly.

It’s not clear to me exactly what strategy you’re attempting. I can see at 
least 4 possibilities:

1. The scroll view is itself a child (or a sibling) of a view that represents 
the circle.

2. The circle view is a child of the scroll view, but not of its content view.

3. The circle view is a child of the scroll view’s content view, but is a 
different view from the image view.

4. The circle view and image view are the same custom view, with gestures to 
pan and scale cause the image to move/resize relative to the circle.

So I’m not sure whether scrolling the scroll view is the UI for positioning the 
image relative to the circle, or is the UI for scrolling. Similarly, I’m not 
sure if scaling from the scroll view is the UI for scaling the image relative 
to the circle, or is just the UI for zooming in.

I’m inclined to think that using the scroll view to position the image relative 
to the circle isn’t semantically correct, but perhaps that’s not what you’re 
doing anyway.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-23 Thread Quincey Morris
On Feb 23, 2016, at 04:28 , Charles Jenkins  wrote:
> 
> My scrollview containing an imageview seems to work just fine: I can scale 
> and crop an image with no problem. But I’m having difficulty getting the 
> desired “crop circle” to hover over the scrollview properly.

It’s not clear to me exactly what strategy you’re attempting. I can see at 
least 4 possibilities:

1. The scroll view is itself a child (or a sibling) of a view that represents 
the circle.

2. The circle view is a child of the scroll view, but not of its content view.

3. The circle view is a child of the scroll view’s content view, but is a 
different view from the image view.

4. The circle view and image view are the same custom view, with gestures to 
pan and scale cause the image to move/resize relative to the circle.

So I’m not sure whether scrolling the scroll view is the UI for positioning the 
image relative to the circle, or is the UI for scrolling. Similarly, I’m not 
sure if scaling from the scroll view is the UI for scaling the image relative 
to the circle, or is just the UI for zooming in.

I’m inclined to think that using the scroll view to position the image relative 
to the circle isn’t semantically correct, but perhaps that’s not what you’re 
doing anyway.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-23 Thread Jonathan Hull
Have you looked at cocoa controls?  I am pretty sure I have seen a few open 
source projects that do this.
www.cocoacontrols.com 

Thanks,
Jon

> On Feb 23, 2016, at 4:28 AM, Charles Jenkins  wrote:
> 
> Still struggling with this… My scrollview containing an imageview seems to 
> work just fine: I can scale and crop an image with no problem. But I’m having 
> difficulty getting the desired “crop circle” to hover over the scrollview 
> properly. When I add it to the main view (not the scrollview) at runtime, I 
> try using autolayout constraints to pin it to the left, top, right, and 
> bottom of the scrollview; but it always appears positioned elsewhere, as if 
> it’s not resizing due to the constraints.
> 
> I viewDidLoad(), I create each constraint like this:
> 
>   let lc = NSLayoutConstraint( overlay, attribute: .Left, relatedBy: 
> .Equal, toItem: scrollView, attribute: .Left, multiplier: 1, constant: 0 )
> 
> And when all four have been created, I call 
> NSLayoutConstraint.activateConstraints( [ lc, tc, rc, bc ] )
> 
> Is this the wrong approach? What’s the right way to display a simple overlay 
> above the content of a scrollView?
> 
> -- 
> 
> Charles
> 
> On February 21, 2016 at 20:48:18, Charles Jenkins (cejw...@gmail.com) wrote:
> 
> I’m trying to do something that’s so simple, conceptually, that I’m sure 
> there’s a demo program for it, if only I could find the right Google search 
> to locate it.
> 
> I want to allow iOS users to select an image (either from the camera roll or 
> by taking a photo) and display it in a CIRCLE for cropping. Users should be 
> able to scale and position the image as they like to fit within the circle, 
> then tap a DONE button to have the image cropped and saved into my app’s 
> image store.
> 
> I spent all day today screwing around making a view controller with a 
> scrollview containing an imageview, and I haven’t figured out how to make the 
> circle overlay correctly to fit over the scrollview.
> 
> Does anybody know of a demo program that’ll show me how to do this?
> 
> -- 
> 
> Charles
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/jhull%40gbis.com
> 
> This email sent to jh...@gbis.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-23 Thread Charles Jenkins
Still struggling with this… My scrollview containing an imageview seems to work 
just fine: I can scale and crop an image with no problem. But I’m having 
difficulty getting the desired “crop circle” to hover over the scrollview 
properly. When I add it to the main view (not the scrollview) at runtime, I try 
using autolayout constraints to pin it to the left, top, right, and bottom of 
the scrollview; but it always appears positioned elsewhere, as if it’s not 
resizing due to the constraints.

I viewDidLoad(), I create each constraint like this:

let lc = NSLayoutConstraint( overlay, attribute: .Left, relatedBy: 
.Equal, toItem: scrollView, attribute: .Left, multiplier: 1, constant: 0 )

And when all four have been created, I call 
NSLayoutConstraint.activateConstraints( [ lc, tc, rc, bc ] )

Is this the wrong approach? What’s the right way to display a simple overlay 
above the content of a scrollView?

-- 

Charles

On February 21, 2016 at 20:48:18, Charles Jenkins (cejw...@gmail.com) wrote:

I’m trying to do something that’s so simple, conceptually, that I’m sure 
there’s a demo program for it, if only I could find the right Google search to 
locate it.

I want to allow iOS users to select an image (either from the camera roll or by 
taking a photo) and display it in a CIRCLE for cropping. Users should be able 
to scale and position the image as they like to fit within the circle, then tap 
a DONE button to have the image cropped and saved into my app’s image store.

I spent all day today screwing around making a view controller with a 
scrollview containing an imageview, and I haven’t figured out how to make the 
circle overlay correctly to fit over the scrollview.

Does anybody know of a demo program that’ll show me how to do this?

-- 

Charles
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

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

2016-02-21 Thread Charles Jenkins
I’m trying to do something that’s so simple, conceptually, that I’m sure 
there’s a demo program for it, if only I could find the right Google search to 
locate it.

I want to allow iOS users to select an image (either from the camera roll or by 
taking a photo) and display it in a CIRCLE for cropping. Users should be able 
to scale and position the image as they like to fit within the circle, then tap 
a DONE button to have the image cropped and saved into my app’s image store.

I spent all day today screwing around making a view controller with a 
scrollview containing an imageview, and I haven’t figured out how to make the 
circle overlay correctly to fit over the scrollview.

Does anybody know of a demo program that’ll show me how to do this?

-- 

Charles
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com