uiimageview - Objective C - Adjust height of image in image view automatically after original size -


i developing app show flags countries places, after looking @ flags realized flags format different every country. therefor height of image view automatically adjust self width set. example: standard width flags: 100 px usa : height: 50px uk: height 56 px russia: height 34px

i have no idea how solve this, help! best if done automatically - without me needing create example arrays or every flag adjust size.

this ratio problem. suppose english flag 120x80px. want 100px wide. how tall be? have scale width , height same ratio.

first of all, calculate ratio between desired width of flag , actual width:

cgfloat ratio = 100.0f / 120.0f; 

that gives ratio of 0.83. can calculate display height multiplying actual height ratio:

cgfloat height = 80.0f * 0.83; 

the display height 66.4px.


here's neat thing: uiimageview you. if specify width of image view , set content mode uiviewcontentmodescaleaspectfit hard work automatically.

see question:

how scale uiimageview proportionally?


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -