KyleGoddard / KGFloatingDrawer

A floating navigation drawer with an interesting animated presentation written in Swift.
MIT License
499 stars 79 forks source link

drawer size not correct on iphone4s #8

Closed aotian16 closed 9 years ago

aotian16 commented 9 years ago

when i run KGFloatingDrawer app on my iphone4s, drawer only show parts of it, about 1/3.

on iphone6 is ok. simulator iphone4s is also ok.

sorry for my poor english.

KyleGoddard commented 9 years ago

hmm, I'll see if I can find an old device and have a look.

aotian16 commented 9 years ago

I update my iphone4s os version from 7.1 to 8.4. and it's ok now.

Maybe it's a bug of os 7.1 version?

thanks to your nice project

KyleGoddard commented 9 years ago

that would be why, the deployment target must be 8.0+

aotian16 commented 9 years ago

what should i do if i want to run on 7+? In my country, still lots of 7+

KyleGoddard commented 9 years ago

You could look at the project that KGFloatingDrawer was based on https://github.com/JVillella/JVFloatingDrawer. The deployment target for this is iOS 7.

aotian16 commented 9 years ago

Thank you , but i am a newbee on swift, and not familiar with obj-c. I notice that JVFloatingDrawer have the same issue too.

https://github.com/JVillella/JVFloatingDrawer/issues/9

I try to fix this with code bellow, and looks like work fine

    private func applyTransforms(side: KGDrawerSide, drawerView: UIView, centerView: UIView) {

        let direction = side.rawValue
        let sideWidth = CGRectGetWidth(drawerView.bounds)
        let centerWidth = CGRectGetWidth(centerView.bounds)
        let centerHorizontalOffset = direction * sideWidth
        let scaledCenterViewHorizontalOffset = direction * (sideWidth - (centerWidth - kKGCenterViewDestinationScale * centerWidth) / 2.0)

//        let sideTransform = CGAffineTransformMakeTranslation(centerHorizontalOffset, 0.0)
//        drawerView.transform = sideTransform
//        
//        let centerTranslate = CGAffineTransformMakeTranslation(scaledCenterViewHorizontalOffset, 0.0)
//        let centerScale = CGAffineTransformMakeScale(kKGCenterViewDestinationScale, kKGCenterViewDestinationScale)
//        centerView.transform = CGAffineTransformConcat(centerScale, centerTranslate)

        let sideTranslate3D = CATransform3DMakeTranslation(centerHorizontalOffset, 0.0, 0.0)
        drawerView.layer.transform = sideTranslate3D

        let centerTranslate3D = CATransform3DMakeTranslation(scaledCenterViewHorizontalOffset, 0.0, 0.0)
        let centerScale3D = CATransform3DMakeScale(kKGCenterViewDestinationScale, kKGCenterViewDestinationScale, 1.0)

        centerView.layer.transform = CATransform3DConcat(centerScale3D, centerTranslate3D)
    }