ios - 更改自定义进度条的高度不起作用 Xamarin.Forms iOS
<p><p>我尝试使用 PCL 更改 xamarin.forms 中进度条的高度。
解决方案似乎是这样的:<a href="https://stackoverflow.com/questions/33673893/xamarin-forms-increase-progressbar-height" rel="noreferrer noopener nofollow">Xamarin forms increase ProgressBar height</a> </p>
<p>在 android 上这工作正常,但在 iOS 上它不工作。
有什么建议吗?</p>
<p><strong>颜色和圆角半径更改正在起作用!</strong></p>
<p>我的代码:</p>
<pre><code>using ZFBookingAid.iOS;
using CoreGraphics;
using Foundation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
namespace ZFBookingAid.iOS
{
public class CustomProgressBarRenderer : ProgressBarRenderer
{
protected override void OnElementChanged(
ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
{
base.OnElementChanged(e);
Control.ProgressTintColor = Color.FromRgb(213, 176, 118).ToUIColor();// This changes the color of the progress
Control.TrackTintColor = Color.FromRgb(255, 255, 255).ToUIColor(); //color where is "no progress"
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
var X = 0.5f;
var Y = 30.0f;
CGAffineTransform transform = CGAffineTransform.MakeScale(X, Y);
Control.Transform = transform;
this.ClipsToBounds = true;
this.Layer.MasksToBounds = true;
this.Layer.CornerRadius = 5; // This is for rounded corners.
}
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>public async override void LayoutSubviews()
{
await Task.Delay(100);
base.LayoutSubviews();
CGAffineTransform transform = CGAffineTransform.MakeScale(1.2f, 2.5f);
transform.TransformSize(this.Frame.Size);
this.Transform = transform;
this.ClipsToBounds = true;
this.Layer.MasksToBounds = true;
}
</code></pre>
<p>这就是我修复进度条高度问题的方法。</p></p>
<p style="font-size: 20px;">关于ios - 更改自定义进度条的高度不起作用 Xamarin.Forms iOS,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/43317535/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/43317535/
</a>
</p>
页:
[1]