开发者

UIViews laid out in Interface Builder changes position during execution (UIViewContentMode)

开发者 https://www.devze.com 2023-01-25 13:48 出处:网络
I have some graphics that is already scaled and cut correctly for my project. I choose 开发者_JAVA技巧to build the UI in IB and positioned everything correctly, under size and position I left it a \"F

I have some graphics that is already scaled and cut correctly for my project. I choose 开发者_JAVA技巧to build the UI in IB and positioned everything correctly, under size and position I left it a "Frame" (instead of layout).

At runtime my graphics is moved and stretched according to which UIViewContentMode I set. If I was doing this completely in code and set a frame and no UIViewContentMode, Cocoa would respect this and leave the graphics alone. However IB does things a bit different.

I think my problem is that I don't precisely understand what the different UIViewContentMode's does and I can't find the correct one to "turn off" the manipulation of the graphics at runtime.

Can someone give my a little help on this one:)

Thanks in regards.


If you don't set the value, the default is UIViewContentModeScaleToFill. If doing it in code and then calling setNeedsDisplay does it "scale to fill"? I think it depends on how you "do it in code" when the content mode is enforced - I assume IB is doing some extra stuff in the init to apply the content mode that you are not doing in code.

Anyway, if you don't want it to "scale" you can pick any of the UIViewContentMode operations that don't have the word "Scale" in the name. Review the UIViewContentMode enum for details on what each one does.

0

精彩评论

暂无评论...
验证码 换一张
取 消