Monotouch.Dialog在Section中拉伸UIView

时间:2013-05-27 20:15:00

标签: c# iphone xamarin.ios xamarin monotouch.dialog

我有一个图像,一个徽标,使用此代码显示在我的Monotouch.Dialog顶部:

        var logo = new UIImageView(logonLogoPNG)
            {
                AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin |
                                   UIViewAutoresizing.FlexibleLeftMargin | 
                                   UIViewAutoresizing.FlexibleBottomMargin |
                                   UIViewAutoresizing.FlexibleRightMargin,
            };
        var secLogo = new Section(logo);

问题在于,当iPad中的表单显示时,徽标会延伸。 Autosizingmask似乎没有帮助。

如何停止伸展?

1 个答案:

答案 0 :(得分:0)

这是我的解决方案:

        //Add a centered Logo in the top Section of the Monotouch.dialog
        var logo = new UIImageView(image) 
                       {  AutoresizingMask = UIViewAutoresizing.FlexibleMargins};
        var logoView = new UIView(new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width,logo.Frame.Height));
        logo.Center = logoView.Center;
        logoView.AddSubview(logo);

诀窍是将徽标的中心设置为包含视图的中心,然后使徽标流动具有灵活的边距。