Re: CALayer kCAGravityResizeAspectFill and kCAGravityTop

2016-09-23 Thread Torsten Curdt
>
>
> Its still an option, especially if you are otherwise using UIViews –
> UIView.maskView would do the trick.
>

Wow - I wasn't even aware that exists. Nice!

Thanks!
___

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: CALayer kCAGravityResizeAspectFill and kCAGravityTop

2016-09-21 Thread David Duncan

> On Sep 21, 2016, at 11:44 AM, Torsten Curdt  wrote:
> 
> There isn’t an option to fill width and align top. The more general 
> recommendation in this space however would be to use a UIImageView, which has 
> all the same options but participates in higher level layout (including the 
> content of autoResizingMasks, and also auto layout).
> 
> I am using the layer as a mask - so the UIImageView isn't really an option.

Its still an option, especially if you are otherwise using UIViews – 
UIView.maskView would do the trick.

> BUT I just found that adjusting the contentsRect to the right ratio does the 
> trick.

If you are going to do that, you might as well just calculate the aspect ratio 
as well.

Keep in mind that if the image you are using as a mask is not fully under your 
control, you will also have to adapt for the image orientation – if the image 
is not oriented up, then you need to rotate as well.

> 
> cheers,
> Torsten

--
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: CALayer kCAGravityResizeAspectFill and kCAGravityTop

2016-09-21 Thread Torsten Curdt
>
> There isn’t an option to fill width and align top. The more general
> recommendation in this space however would be to use a UIImageView, which
> has all the same options but participates in higher level layout (including
> the content of autoResizingMasks, and also auto layout).
>

I am using the layer as a mask - so the UIImageView isn't really an option.
BUT I just found that adjusting the contentsRect to the right ratio does
the trick.

cheers,
Torsten
___

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: CALayer kCAGravityResizeAspectFill and kCAGravityTop

2016-09-21 Thread David Duncan

> On Sep 21, 2016, at 11:18 AM, Torsten Curdt  wrote:
> 
> On iOS I want to fill a layer with an image.
> The width should be filled and the image should retain its aspect ratio.
> This
> 
>layer.contents = image.cgImage
>layer.contentsGravity = kCAGravityResizeAspectFill
> 
> almost does the right thing - but it positions the image at the centers.
> I would like to have it positioned at the top.

There isn’t an option to fill width and align top. The more general 
recommendation in this space however would be to use a UIImageView, which has 
all the same options but participates in higher level layout (including the 
content of autoResizingMasks, and also auto layout).

> 
> While looking at the docs for CALayer I found "autoresizingMask" but that
> seems to be macOS only.
> 
> Any pointers?
> 
> cheers,
> Torsten
> ___
> 
> 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

CALayer kCAGravityResizeAspectFill and kCAGravityTop

2016-09-21 Thread Torsten Curdt
On iOS I want to fill a layer with an image.
The width should be filled and the image should retain its aspect ratio.
This

layer.contents = image.cgImage
layer.contentsGravity = kCAGravityResizeAspectFill

almost does the right thing - but it positions the image at the centers.
I would like to have it positioned at the top.

While looking at the docs for CALayer I found "autoresizingMask" but that
seems to be macOS only.

Any pointers?

cheers,
Torsten
___

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