ios - UIImageView height not height of child image's height after autolayout constraints. -
my goal:
- image's width == width of screen.
- aspect ratio stays in tact, height adjust automatically.
- the height of uiimageview == height of child image's height. (what not working see below)
i using xcode 6, autolayout constraints storyboard complete this.
look @ following 2 screenshots see (1) app looks , (2) need fixed.
as can see on left side of screenshot, have storyboard imageview selected.
- the imageview's width covering screen's width
- i have set background color black can see how imageview stretches it's height.
- look on far right side of screenshot see 3 constraints have set far. first 2 fit imageview on screen , last make sure goes below navigation bar. pretty normal constraints.
so far looking @ screenshot, first 2 goals satisfied. image's width width of screen (you can see on iphone 4 preview in screenshot) , aspect ratio stays in tact.
now, issue having...
how rid of black space above , below image? black coming imageview. i want imageview same height image inside of set as.
some guesses have:
- should create constraints each of size classes available? instead of editing wany , hany, should set imageview's height constraint iphones , 1 ipad using specific size classes?
- if remove leading , trailing contraints, seems rid of black space imageview doesn't fit on screen anymore constraint needed. other way make imageview's width width of screen instead of using these constraints?
add following constraint imageview:
"aspect ratio" constraint multiplier set imageview's aspect ratio.
for example:
if dimension of image (600 x 300), "aspect ratio" mutltiplier 2:1
Comments
Post a Comment