Dynamic MapPin image not scaling correctly IOS 8 Swift -


hello i'm working mapkit, ios 8, , swift , i'm using custom map pins display annotation view.

i'm pulling map data server etc. , have property tell me wether display custom map pin or regular map pin that's part of map kit.

i added extension mkannotationview asynchronously loads image nsurl , works fine. use similar extension uiimageview tableviews , async loading.

if have image asset (map pin) stored locally in image assets folder results map pin on map expected correct dimensions , no distortion etc.

normal map pin image stored locally on device

the problem when download exact same image server , set image, larger 1 stored in image assets , distorted.

distorted image server

so know guys & gals know problem. again both same image same size , dimensions 50x82 72 dpi.

things have tried: thought might ios thing images being 2x etc. cut dimensions in half image coming server 25x41 , didn't help. thought might have point issue , not pixel issue. changed points half resolution , doubled dpi.

sadly none of helped still getting distorted images. want dynamic because during different seasons , holidays want able change theme of map pin without making user update app.

any appreciated.

alright figured out. image 2x scale needed (obvious) had scale down using graphics context (redraw it) using retuned image server can see how done.

        let newsize = cgsize(width: image.size.width/2.0, height: image.size.height/2.0)          uigraphicsbeginimagecontextwithoptions(newsize, false, 0.0)          image.drawinrect(cgrect(origin: cgpointzero, size: newsize))          let scaledimage = uigraphicsgetimagefromcurrentimagecontext()          uigraphicsendimagecontext()          dispatch_async(dispatch_get_main_queue(), { () -> void in              self.image = scaledimage         }) 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -