2017-04-10 58 views
2

我試圖使用PCL更改xamarin.forms中進度條的高度。 的解決方案似乎是這樣的:Xamarin forms increase ProgressBar height更改自定義progresssbar不工作的高度Xamarin.Forms iOS

在Android上這工作正常,但在iOS上它不工作。 有什麼建議嗎?

顏色和圓角半徑變化正在工作!

我的代碼:

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; 

[assembly: ExportRenderer(typeof(ProgressBar), typeof(CustomProgressBarRenderer))] 
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. 

     } 
    } 
} 

回答

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


     } 

我這是怎麼固定的進度條問題的高度。