c# - Problems creating a round UIImageView with Storyboard [Xamarin] -


i facing weird problem , sure oversee obvious: want round image this:

i perform following action round corners of uiimageview:

        testimage.layer.cornerradius = testimage.frame.size.height * 0.5f;         testimage.clipstobounds = true; 

in storyboard imageview has constraint left , right of 60, top 92 , aspectratio of 1:1.

enter image description here

however, when run app receive following on iphone 6plus: enter image description here

i played bit around cornerradius , produce required circle 100 on iphone 5, 125 on iphone 6 , 150 on iphone 6plus.

when generate code this:

        var testimage = new uiimageview(new coregraphics.cgrect(0, 0, 150, 150));         testimage.image = uiimage.fromfile ("kitten.jpg");         testimage.layer.cornerradius = testimage.frame.size.height * 0.5f;         testimage.clipstobounds = true;         view.add (testimage); 

i expected result: enter image description here

am doing wrong storyboard?

thanks in advance!

i've double-checked in xcode, i'll put in answer:

in first instance, you're assuming height , width equal because aspect ratio set 1:1; in second instance, you're creating uiimageview that's setting height , width equal values. if set priority of aspect ratio constraint number higher priority of other constraint, should circle.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -