Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
624 views
in Technique[技术] by (71.8m points)

ios - What constraints should be given to increase size of imageview with respect to device screen size without reducing image clarity

I have to show an imageview in a universal app ans it's size should increase as the screen design in every devices without reducing image quality. The image given to the imageview is a static image. If I use static width and height constraints using size classes it will work. But I don't think it as the correct way. If i use width & height Proportional to the superview, it increases the image height but image clarity reduced in ipads. Any suggestion will be helpfull.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To make Imageviewsize respect to device for universal application , you need to give correct multipler to imageview.

please follow step to get desire output,


Step 1 :- Set Aspect Ratio to your imageview . (you can also set leading and trialing top , bottom etc. and then give aspect ratio.)

Aspect ration required to maintain to set image equal width and Height (Square)

enter image description here


Step 2 :- Set Horizontal center and vertically center imageview . (it will be differ according to your requirement , you can also take this step as step 1 and then set aspect ratio)

enter image description here


Step 3 :- Set Equal height to Superview from imageview.

(Don't panic , you will get warning to update frames or constrain but don't update it)

enter image description here


Step 4 :- Count Accurate Multiplier.

imageviewHeight / superview's height = Accurate Multipliar

Here ,

imageviewheight = 200 , superviewheight=600   so ,

200(imageviewheight)/600(superviewheight)=0.333 

(set multipler to imageview where proposanal height = superview)

enter image description here


Step 5 :- check output to different simulator.

enter image description here

I hope this detail explanation is enought to understand your question.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...