Re: CALayer kCAGravityResizeAspectFill and kCAGravityTop
Re: CALayer kCAGravityResizeAspectFill and kCAGravityTop
- Subject: Re: CALayer kCAGravityResizeAspectFill and kCAGravityTop
- From: David Duncan <email@hidden>
- Date: Wed, 21 Sep 2016 11:33:57 -0700
> On Sep 21, 2016, at 11:18 AM, Torsten Curdt <email@hidden> 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 (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
--
David Duncan
_______________________________________________
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