using System;
using UIKit;
using System.Drawing;
using CoreAnimation; namespace PMM
{
public class ProgressCircleView : UIView
{
protected CAShapeLayer _progressCircle;
protected CAShapeLayer PageGrayCircle;
public override CoreGraphics.CGRect Bounds {
get
{
return base.Bounds;
}
set {
base.Bounds = value;
GrayCircle ();
}
} public ProgressCircleView ()
{
GrayCircle ();
} /// <summary>
/// Redraws the progress circle. If the circle is already on the screen, it removes that one and creates a new one using the
/// current properties of the view
/// </summary>
void RedrawCircle ()
{ var centerPoint = new PointF ((float)this.Bounds.Width , (float)this.Bounds.Height );
UIBezierPath circlePath = UIBezierPath.FromArc (centerPoint, this.Bounds.Width * .5f, (float)(-. * Math.PI), (float)(1.5 * Math.PI), true); _progressCircle = new CAShapeLayer (); _progressCircle.Path = circlePath.CGPath;
_progressCircle.StrokeColor = UIColor.Red.CGColor;
_progressCircle.FillColor = UIColor.Clear.CGColor;
_progressCircle.LineWidth = 5f;
_progressCircle.LineCap = CAShapeLayer.CapRound;
_progressCircle.StrokeStart = 0f;
_progressCircle.StrokeEnd = 0f;
this.Layer.AddSublayer (_progressCircle); }
void GrayCircle()
{
if (_progressCircle != null && _progressCircle.SuperLayer != null) {
_progressCircle.RemoveFromSuperLayer ();
}
var centerPoint = new PointF ((float)this.Bounds.Width , (float)this.Bounds.Height );
UIBezierPath circlePath = UIBezierPath.FromArc (centerPoint, this.Bounds.Width * .5f, (float)(1.5 * Math.PI), (float)(-. * Math.PI), false); PageGrayCircle = new CAShapeLayer (); PageGrayCircle.Path = circlePath.CGPath;
PageGrayCircle.StrokeColor = UIColor.Gray.CGColor;
PageGrayCircle.FillColor = UIColor.Clear.CGColor;
PageGrayCircle.LineWidth = 4f;
PageGrayCircle.LineCap = CAShapeLayer.CapRound;
PageGrayCircle.StrokeStart = 0f;
PageGrayCircle.StrokeEnd = 0f;
this.Layer.AddSublayer (PageGrayCircle);
RedrawCircle ();
} /// <summary>
/// Updates the progress circle.
/// </summary>
/// <param name="progressPercent">The percentage of the progress. Should be a value between 0.0 and 1.0</param>
public void UpdateProgress(float progressPercent) {
_progressCircle.StrokeEnd = progressPercent;
PageGrayCircle.StrokeEnd = - progressPercent;
}
}
}

xamarin.ios 实现圆形进度条的更多相关文章

  1. Xamarin iOS教程之进度条和滚动视图

    Xamarin iOS教程之进度条和滚动视图 Xamarin iOS 进度条 进度条可以看到每一项任务现在的状态.例如在下载的应用程序中有进度条,用户可以很方便的看到当前程序下载了多少,还剩下多少.Q ...

  2. iOS学习-圆形进度条

    效果: #import <UIKit/UIKit.h> @interface HsProfitRatePieWidgets : UIView { UILabel *_textLabel; ...

  3. iOS之UI--Quartz2D的入门应用--重绘下载圆形进度条

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...

  4. [iOS]圆形进度条及计时功能

    平时用战网安全令的时候很喜欢圆形倒计时的效果,然后简单看了一下Android的圆形进度条,后来又写了一个IOS的.整体界面参照IOS系统的倒计时功能,顺便熟悉了UIPickerView的一些特性的实现 ...

  5. IOS 圆形进度条

    // // CCProgressView.h // Demo // // Created by leao on 2017/8/7. // Copyright © 2017年 zaodao. All r ...

  6. iOS开发笔记-根据frame大小动态调整fontSize的自适应文本及圆形进度条控件的实现

    最近同样是新App,设计稿里出现一种圆形进度条的设计,如下: 想了想,圆形进度条实现起来不难,但是其中显示百分比的文本确需要自适应,虽然可以使用时自己设定文本字体的大小,但是这样显得很麻烦,也很low ...

  7. 移动端纯CSS3制作圆形进度条所遇到的问题

    近日在开发的页面中,需要制作一个动态的圆形进度条,首先想到的是利用两个矩形,宽等于直径的一半,高等于直径,两个矩形利用浮动贴在一起,设置overflow:hidden属性,作为盒子,内部有一个与其宽高 ...

  8. Xamarin XAML语言教程Xamarin.Forms中构建进度条

    Xamarin XAML语言教程Xamarin.Forms中构建进度条 ProgressBar被称为进度条,它类似于没有滑块的滑块控件.进度条总是水平放置的.本节将讲解如何使用进度条. 注意:进度条在 ...

  9. android 自定义控件——(四)圆形进度条

    ----------------------------------↓↓圆形进度条(源代码下有属性解释)↓↓---------------------------------------------- ...

随机推荐

  1. MyBatis学习总结(三)——优化MyBatis配置文件中的配置

    一.连接数据库的配置单独放在一个properties文件中 之前,我们是直接将数据库的连接配置信息写在了MyBatis的conf.xml文件中,如下: 1 <?xml version=" ...

  2. Android笔记——Android内部类

    Java语言允许在类中再定义类,这种在其它类内部定义的类就叫内部类.内部类又分为:常规内部类.局部内部类.匿名内部类和静态嵌套类四种.我们内部类的知识在Android手机开发中经常用到. 一.常规内部 ...

  3. jquery 的队列queue

    使用示列代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  4. How Google TestsSoftware - Part One

    This is the firstin a series of posts on this topic.The one question I get morethan any other is &qu ...

  5. Java基础-接口看下图实现如下接口和类,并完成Adventure中的主方法

    package hanqi; public interface CanSwim { void swim(); } package hanqi; public interface CanFly { pu ...

  6. TSQL 去除重复值

    数据去重主要分为两种情况:第一种是保证Select的全部列无重复:第二种是select的部分字段无重复,而其他字段取特定值. 1,对select的全部字段去重,直接使用distinct 函数 2,对s ...

  7. Windows 10 开始菜单修改程序

    Windows 10虽然恢复了开始菜单,但与经典的菜单相比还是有些变化.对于菜单项中名称过长的只能显示一部分,比如SQL Server Management Studio这种名称比较长的菜单项名称,常 ...

  8. 【WP 8.1开发】手机客户端应用接收推送通知

    上一篇文章中,已经完成了用于发送通知的服务器端,接下来我们就用这个服务端来测试一下. 在开始测试之前,我们要做一个接收通知的WP应用. 1.启动VS Express for Windows,新建项目, ...

  9. 深入理解CSS径向渐变radial-gradient

    × 目录 [1]定义 [2]椭圆圆心 [3]椭圆类型 [4]椭圆大小 [5]色标 [6]重复渐变 [7]其他 前面的话 上篇介绍了线性渐变,本文接着介绍径向渐变的内容 定义 径向渐变,实际上就是椭圆渐 ...

  10. Java多线程系列--“JUC原子类”04之 AtomicReference原子类

    概要 本章对AtomicReference引用类型的原子类进行介绍.内容包括:AtomicReference介绍和函数列表AtomicReference源码分析(基于JDK1.7.0_40)Atomi ...