【发布时间】:2018-03-17 14:23:22
【问题描述】:
我目前在我的 Xamarin 表单中有一个自定义地图渲染器,用于每个平台的原生地图渲染器。
对于 iOS,我正在尝试添加一个跟踪按钮以返回当前位置。
我有创建按钮的代码:
var button = MKUserTrackingButton.FromMapView(Map);
button.Layer.BackgroundColor = UIColor.White.CGColor;
button.Layer.BorderColor = UIColor.FromRGB(211, 211, 211).CGColor;
button.Layer.BorderWidth = 1;
button.Layer.CornerRadius = 5;
button.TranslatesAutoresizingMaskIntoConstraints = false;
Map.AddSubview(button);
但是我需要把它移到右下角(见下图)
所以我只需要这行代码来移动 MAP 视图中的按钮 :)
【问题讨论】:
-
设置按钮的 Frame 以指定相对于父级的位置
-
此代码
button.Frame = new RectangleF(100, 100, 52, 44);不起作用
标签: c# ios xamarin xamarin.forms xamarin.ios