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 自定义控件——(四)圆形进度条
----------------------------------↓↓圆形进度条(源代码下有属性解释)↓↓---------------------------------------------- ...
随机推荐
- 让我欲罢不能的node.js
从我大一接触第一门编程语言C开始,到现在工作三年陆续接触到了C.汇编.C++.C#.Java.JavaScript.PHP,还有一些HTML.CSS神马的,从来没有一门语言让我像对node.js一样的 ...
- easy-ui JOB 及 小记录
$:获取 $.ajax({ type: "POST" , url: "" , cont ...
- PLoP(Pattern Languages of Programs,程序设计的模式语言)
2014/8/1 12:24:21潘加宇 http://www.umlchina.com/News/Content/340.htmPloP大会2014即将举行 PLoP(Pattern Languag ...
- Python学习--06切片
Python里提供了切片(Slice)操作符获取列表里的元素. 示例: >>> L = [1,2,3,4,5] # 取前2个元素,传统方法 >>> [L[0],L[ ...
- Atitit 图像清晰度 模糊度 检测 识别 评价算法 原理
Atitit 图像清晰度 模糊度 检测 识别 评价算法 原理 1.1. 图像边缘一般都是通过对图像进行梯度运算来实现的1 1.2. Remark: 1 1.3. 1.失焦检测. 衡量画面模糊的主要方 ...
- iOS----Xcode6或者Xcode7设置LaunchImage图标
最近设置LaunchImage图标时发现怎么都没有效果,后来发现是Xcode6中新建项目的时候会默认添加一个LaunchScreen.xib的文件,我们启动程序的时候也会发现,加载的时LaunchSc ...
- Liferay7 BPM门户开发之45: 集成Activiti文件上传部署流程BPMN模型
开发文件上传,部署流程模板. 首先,开发jsp页面,deploy.jsp <%@ include file="/init.jsp" %> <h3>${RET ...
- KendoUI系列:Window
1.基本使用 <link href="@Url.Content("~/Content/kendo/2014.1.318/kendo.common.min.css") ...
- transform你不知道的那些事
transform是诸多css3新特性中最打动我的,因为它让方方正正的box module变得真实了. transform通过一组函数实现了对盒子大小.位置.角度的2D或者3D变换.不过很长时间内,我 ...
- Struts2 DomainModel、ModelDriven接收参数
一.DomainModel(域模型) 1. 应用场景:一般我们在struts2的action中接收参数通常是如下方式 package cn.orlion.user; import com.opensy ...