2013-05-27 60 views
1

我有一個形象,一個標誌,這在我的Monotouch.Dialog頂部顯示使用此代碼拉伸的UIView:Monotouch.Dialog第

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

的問題是,當窗體顯示在一臺iPad徽標延伸。 Autosizingmask似乎沒有幫助。

我該如何阻止拉伸?

回答

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); 

訣竅是標誌的中心設置爲包含視圖的中心,然後做出靈活的利潤率標誌流。