xamarin.ios 实现圆形进度条
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 实现圆形进度条的更多相关文章
- Xamarin iOS教程之进度条和滚动视图
Xamarin iOS教程之进度条和滚动视图 Xamarin iOS 进度条 进度条可以看到每一项任务现在的状态.例如在下载的应用程序中有进度条,用户可以很方便的看到当前程序下载了多少,还剩下多少.Q ...
- iOS学习-圆形进度条
效果: #import <UIKit/UIKit.h> @interface HsProfitRatePieWidgets : UIView { UILabel *_textLabel; ...
- iOS之UI--Quartz2D的入门应用--重绘下载圆形进度条
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- [iOS]圆形进度条及计时功能
平时用战网安全令的时候很喜欢圆形倒计时的效果,然后简单看了一下Android的圆形进度条,后来又写了一个IOS的.整体界面参照IOS系统的倒计时功能,顺便熟悉了UIPickerView的一些特性的实现 ...
- IOS 圆形进度条
// // CCProgressView.h // Demo // // Created by leao on 2017/8/7. // Copyright © 2017年 zaodao. All r ...
- iOS开发笔记-根据frame大小动态调整fontSize的自适应文本及圆形进度条控件的实现
最近同样是新App,设计稿里出现一种圆形进度条的设计,如下: 想了想,圆形进度条实现起来不难,但是其中显示百分比的文本确需要自适应,虽然可以使用时自己设定文本字体的大小,但是这样显得很麻烦,也很low ...
- 移动端纯CSS3制作圆形进度条所遇到的问题
近日在开发的页面中,需要制作一个动态的圆形进度条,首先想到的是利用两个矩形,宽等于直径的一半,高等于直径,两个矩形利用浮动贴在一起,设置overflow:hidden属性,作为盒子,内部有一个与其宽高 ...
- Xamarin XAML语言教程Xamarin.Forms中构建进度条
Xamarin XAML语言教程Xamarin.Forms中构建进度条 ProgressBar被称为进度条,它类似于没有滑块的滑块控件.进度条总是水平放置的.本节将讲解如何使用进度条. 注意:进度条在 ...
- android 自定义控件——(四)圆形进度条
----------------------------------↓↓圆形进度条(源代码下有属性解释)↓↓---------------------------------------------- ...
随机推荐
- 如何将GridViewEX升级到UWP(Universal Windows Platform)平台
引言 上一篇文章中,我们主要讲解了如何在保证GridView控件的用户体验基础上,扩展GridView生成GridViewEx控件,增加动态添加新分组功能等,本文在上文的基础上,介绍如何在Window ...
- Node.js与Sails~方法拦截器policies
回到目录 policies sails的方法拦截器类似于.net mvc里的Filter,即它可以作用在controller的action上,在服务器响应指定action之前,对这个action进行拦 ...
- Atitit 图像处理 常用8大滤镜效果 Jhlabs 图像处理类库 java常用图像处理类库
Atitit 图像处理 常用8大滤镜效果 Jhlabs 图像处理类库 java常用图像处理类库1.1. 5种常用的Photoshop滤镜,分别针对照片的曝光.风格色调.黑白照片处理.锐利度.降噪这五大 ...
- Atiti qq空间破解(3)------------gui图形化通用cli执行器atiuse
Atiti qq空间破解(3)------------gui图形化通用cli执行器atiuse 结构:::命令行+以及反馈log框1 cli_guiUI/index.htm1 /AtiPlatf_c ...
- 找到SQL Server的序列号
有时候希望获取当前机器上安装的SQL Server序列号,但注册表中序列号是经过加密的,因此我写了一个小工具获取当前SQL Server的序列号.程序比较粗糙,没有做错误验证. ...
- 拓扑排序(三)之 Java详解
前面分别介绍了拓扑排序的C和C++实现,本文通过Java实现拓扑排序. 目录 1. 拓扑排序介绍 2. 拓扑排序的算法图解 3. 拓扑排序的代码说明 4. 拓扑排序的完整源码和测试程序 转载请注明出处 ...
- c#方法重载,可选参数,命名参数。
其实这里没什么可说哦,c++的语法大同小异.先看一段代码. class Program { public static void Test(int a) { Console.WriteLine(&qu ...
- redis java对象操作
使用Jedis客户端 1. java 对象,需序列化 public class Person implements Serializable { private int id; private Str ...
- web前端学习笔记(CSS变化宽度布局)
一.“1-2-1”单列变宽布局: 对于变宽度的布局,首先要使内容的整体宽度随浏览器窗口宽度的变化而变化.因此中间的container容器中的左右两列的总宽度也会变化,这样就会产生不同的情况.这两列是按 ...
- MySQL修改默认字符集
今天朋友在做某个程序项目时,需要修改MySQL修改默认字符集,搞不好找我帮忙.百度了试了好几篇博文中的方法,最后终于成功了.但是感觉那些博文思路有点乱,所以自己总结下,希望可以帮到遇到同样问题的人. ...