Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-create .xib with auto-layout. Support 3x asset. #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

haxpor
Copy link

@haxpor haxpor commented Sep 27, 2015

Changes

I re-created UI to support auto-layout thus UI will looks okay for all devices.

I added 3 UIView to act as a parent view before we add those layers individually. This to give more control over positioning and management in the long run.

Added support for iPhone 6+ with 3x asset. I simply created 3x asset using TexturePacker with scaling factor of 3/2 (or 1.5). For internal of layer class, I check for [UIScreen mainScreen].scale == 3.0 or not, if so then use scale of 0.35. You can read more information at commit log of 42bde5d

Issues

Anyway, something weird going on.
I don't think it's due to auto-layout because CALayer which we're working with doesn't get effect by it. I just can't modify layer's position, yes, and only position. No matter what I do, it don't get into effect. The layer will be fixed at top right of its attaching view. See more at ViewController.m.

Another one is, if we use INFINITY on iOS 9, the animation's display frame will disappear sometime during the animation, with also when we interact with buttons to pause, continue, stop, and play animation. I changed to use hard-coded high value instead and it works fine.

Result

Tested on iPod Gen 5, and all simulators iOS 9 works as expected except for iPad 2 which will give weird result of positioning.

Result as follows.
screen shot 2015-09-27 at 7 58 05 pm
ipad air
ipad 2

Making the system awares of 3x content makes us need to create launchscreens for 4.7, and 5.5' of iphone too.
Re-layout to add support for auto-layout, and properly show the content for all devices.
It works with all iphone devices type, but doesn't work for iPad 2.
The position of CALayer cannot be changed, this might due to the constraints imposed in the Interface builder.

3x asset is created from 2x asset thus it doesn't look high quality.

Re-created as well the .xib for ViewController to support auto layout and show it correctly.
In .xib of ViewController, changed to use UIView instead of UIImageView.
Re-export 3x asset with scaling factor of 1.5 (or 3/2) from 2x asset via TexturePacker.

But 3x asset will be scaled down by 15% (divide by 1.15) to fit iPhone 6+ screen at the end.
Thus the actual scaling factor in effect is 1.5/1.15 = 1.30434782609 (~1.30).
Then from scaling factor used in CAWSpriteCoreLayer to scale down from retina screen is 0.5.
It increases to 0.5*1.3 = 0.65 or 15%. This means in final, we have a bigger scaling factor;
that is 0.5 - 0.15 = 0.35.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant