UIButtons在UIImageView上在设计时与运行时创建的显示方式不同

本文关键字:创建 显示方式 运行时 UIImageView UIButtons | 更新日期: 2023-09-27 18:30:45

我在.xib文件中添加了一些UIButton对象,并使用代码添加了一些UIButton对象。

但现在我面临一个问题。在缩放 UIImageView 时,通过代码添加的 UIButton 显示在 UIImageView 上,使用 .xib 文件添加的 UIButton 显示在 UIImageView 下方。

UIButton的代码与代码一起添加:

btnBrightness = UIButton.FromType (UIButtonType.RoundedRect);
btnBrightness.Frame = new RectangleF (540, 20, 95, 37);
btnBrightness.SetTitle ("Brightness", UIControlState.Normal);

更多详情:单点触控

UIButtons在UIImageView上在设计时与运行时创建的显示方式不同

解决我只是在ViewDidLoad()中添加代码行,即

this.Add(UIImageView)

使用这条线 它的工作是我想要的。

为所有按钮创建一个容器视图,并将按钮添加到其中

mainView.InsertSubview(buttonContainerView,mainView.Subviews.Count);