-
Notifications
You must be signed in to change notification settings - Fork 59
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
Resolves issue #5 #7
Conversation
Issue #5 is high on the priority list, thanks for taking this up! |
Changed sizeForDevice... to sizeForInterface (language) Added bool method
I agree about the sublayers thing. That was pretty hacky. I changed it to only apply transforms to the context when the interface is in landscape. I noticed the status bar layers already rendered correctly when in landscape and gets messed up when applying the transforms to the context so I also check the layer transform to make sure it needs to be applied to the context. I also modified the methods I added just to reflect more concise language. |
Instead of checking for transform identity now check if the layer has the status bar as a delegate.
// if interface is in landscape, apply transforms to context for layers not in the status bar | ||
if (![self isInterfaceInPortrait] && ![layer.delegate isKindOfClass:NSClassFromString(@"UIStatusBarWindow")]) { | ||
CGContextTranslateCTM(ctx, 0, size.height); | ||
CGContextRotateCTM(ctx, -M_PI_2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not quite right yet. This works for device orientation left, but fails if the device is rotated to the right. Since rotated the same way independent of the device orientation, it will show the UI upside down for one of the device rotations?
Check for both orientations could be done like so:
if (orientation==UIInterfaceOrientationLandscapeLeft) {
CGContextTranslateCTM(ctx, size.width, 0);
CGContextRotateCTM(ctx, M_PI_2);
} else {
CGContextTranslateCTM(ctx, 0, size.height);
CGContextRotateCTM(ctx, -M_PI_2);
}
The UI seems to be flipped (see how the shadow is on the top right instead of bottom right). I don't really understand why though. Will try look into it in more detail tonight, but maybe you already have guess or some solution up your sleeve.
(Top view: PSD, bottom view: Simulator)
I've played around a bit more. It seems that as long as there is not rotation of the graphics context involved, the rendered shadow is correct. There's a radar on a related issue raised before by @garrettmoon (and commented on by @alexleutgoeb): http://openradar.appspot.com/8571017. As a workaround, rendering to UIWindow and then rotating the generated image might be a good work around? |
I've now also file a radar (rdar://17035663) for the issue. I think the best would be now to go with the route of rendering the UIWindow and rotating the generated image, as stated above, @jwalapr what you think? Also please note that I had to make some modifications to the API, to make it saner to work with. The API should be pretty stable now as is. The podspec (v0.2.1) is updated to point to the new API. |
Conflicts: MMLayershots/MMLayershots.m
Just changed it to apply the transforms to the generated images. Let me know what you think. |
@jwalapr Merged, thanks! I've bumped up the podspec version to include your change and updated the README to mention you as the originator of the fix. |
Added to .gitignore.
Added sizeForDeviceOrientation method.
psdRepresentationForScreen can create psd document with landscape dimensions.
Referred to screen size in context and rendered sublayer with transformation. (Perhaps there's a better way to do it).