在Xamarin iOS中调整UIView的大小

时间:2018-10-01 11:12:56

标签: c# ios xamarin

我想知道为什么我不能像通常在Swift中那样设置view.Frame的值。现在,我正在使用C#Xamarin应用程序并尝试调整UIView的大小,但它没有响应任何方法,因此始终保持不变。当我尝试更改View.Frame

  

“无法修改'UIView.Frame'的返回值,因为它不是   变量”

。我试图更改可以适合屏幕的UIView框架,但是此选项不起作用。如何更改适合每个屏幕的UIView框架?

        public void NotchNavBarCreator(UIView bar, UINavigationBar barItem) {
           CGRect barfr = bar.Frame;
           CGRect baritfr = barItem.Frame;
           barfr.Width = this.View.Bounds.Width;
           baritfr.Width = this.View.Bounds.Width;
           bar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
        }

1 个答案:

答案 0 :(得分:1)

您必须像这样重新设置Frame变量:

pthread_create()

因此,如果您只想更改宽度,请执行以下操作:

bar.Frame = new CGRect(x: 0, y: 0, width: 123, height: 321);