澳门新蒲京娱乐

图片 13
接口使用OpenCV的方法,应用于图像的简单变换

Python实现简单的多任务mysql转xml的方法,Xml文件添加字节属性的方法【新蒲京官方下载】

不会重叠

效果图

先上海体育场所(做出来的功用正是下图的标准)

先上海体育场地(做出来的作用就是下图的典范)

新蒲京官方下载 11.效果图-w220

新蒲京官方下载 2

图中不管每种扇形多小,都得以从指点线处将辅导的多寡分割开来,不会重叠。

1.效果图-w220

  • 急需给图中数据做个模型

图中不管每一种扇形多小,都足以从指点线处将教导的多寡分割开来,不会重叠。

第一步

@interface DVFoodPieModel : NSObject/** 名称 */@property (copy, nonatomic) NSString *name;/** 数值 */@property (assign, nonatomic) CGFloat value;/** 比例 */@property (assign, nonatomic) CGFloat rate;@end

内需给图中数量做个模型

  • 前几天先把饼图中间的圆形做出来,这几个未有何难度,直接贴代码
@interface DVFoodPieModel : NSObject
/**
 名称
 */
@property (copy, nonatomic) NSString *name;

/**
 数值
 */
@property (assign, nonatomic) CGFloat value;

/**
 比例
 */
@property (assign, nonatomic) CGFloat rate;
@end
  1. 在.h文件中

第二步

近日先把饼图中间的圆形做出来,那些未有啥样难度,直接贴代码

@interface DVPieCenterView : UIView @property (strong, nonatomic) UILabel *nameLabel; @end

在.h文件中

  1. 在.m文件中
@interface DVPieCenterView : UIView 
@property (strong, nonatomic) UILabel *nameLabel; 
@end

在.m文件中

 @interface DVPieCenterView ()@property (strong, nonatomic) UIView *centerView;@end@implementation DVPieCenterView- (instancetype)initWithFrame:frame { if (self = [super initWithFrame:frame]) { self.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.4]; UIView *centerView = [[UIView alloc] init]; centerView.backgroundColor = [UIColor whiteColor]; [self addSubview:centerView]; self.centerView = centerView; UILabel *nameLabel = [[UILabel alloc] init]; nameLabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1]; nameLabel.font = [UIFont systemFontOfSize:18]; nameLabel.textAlignment = NSTextAlignmentCenter; self.nameLabel = nameLabel; [centerView addSubview:nameLabel]; } return self;}- layoutSubviews { [super layoutSubviews]; self.layer.cornerRadius = self.frame.size.width * 0.5; self.layer.masksToBounds = true; self.centerView.frame = CGRectMake(6, 6, self.frame.size.width - 6 * 2, self.frame.size.height - 6 * 2); self.centerView.layer.cornerRadius = self.centerView.frame.size.width * 0.5; self.centerView.layer.masksToBounds = true; self.nameLabel.frame = self.centerView.bounds;}
@interface DVPieCenterView ()
@property (strong, nonatomic) UIView *centerView;
@end
@implementation DVPieCenterView
- (instancetype)initWithFrame:(CGRect)frame {
 if (self = [super initWithFrame:frame]) {
  self.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.4];
  UIView *centerView = [[UIView alloc] init];
  centerView.backgroundColor = [UIColor whiteColor];
  [self addSubview:centerView];
  self.centerView = centerView;
  UILabel *nameLabel = [[UILabel alloc] init];
  nameLabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
  nameLabel.font = [UIFont systemFontOfSize:18];
  nameLabel.textAlignment = NSTextAlignmentCenter;
  self.nameLabel = nameLabel;
  [centerView addSubview:nameLabel];
 }
 return self;
}


- (void)layoutSubviews {
 [super layoutSubviews];
 self.layer.cornerRadius = self.frame.size.width * 0.5;
 self.layer.masksToBounds = true;
 self.centerView.frame = CGRectMake(6, 6, self.frame.size.width - 6 * 2, self.frame.size.height - 6 * 2);
 self.centerView.layer.cornerRadius = self.centerView.frame.size.width * 0.5;
 self.centerView.layer.masksToBounds = true;
 self.nameLabel.frame = self.centerView.bounds;
}

露马脚的唯有.h文件中的namelabel,必要中间展现文字时,给nameLabel的text赋值就好了

露马脚的只有.h文件中的namelabel,需求中间展现文字时,给nameLabel的text赋值就好了

  • 方今就成立一个承接UIView的视图,用来画饼状图和教导线以及数额

第三步

在.h文件中要求有数量数组,还会有中间突显的文字,以及三个draw方法(draw方法纯属个人习于旧贯,在数量总体赋值达成后,调用该方法开展写生)

后天就创办贰个承袭UIView的视图,用来画饼状图和带领线以及数额

@interface DVPieChart : UIView/** 数据数组 */@property (strong, nonatomic) NSArray *dataArray;/** 标题 */@property (copy, nonatomic) NSString *title;/** 绘制方法 */- draw;@end

在.h文件中需求有多少数组,还应该有中间呈现的文字,以及3个draw方法(draw方法纯属个人习于旧贯,在数量总体赋值完毕后,调用该格局开始展览写生)

在调用draw方法前应明确数据总体赋值达成,绘制专门的学问其实是在-
drawRect:rect方法中完结的,所以.h文件中的draw方法只是来调用系统方法的

@interface DVPieChart : UIView
/**
 数据数组
 */
@property (strong, nonatomic) NSArray *dataArray;
/**
 标题
 */
@property (copy, nonatomic) NSString *title;
/**
 绘制方法
 */
- (void)draw;
@end
  • 在.m文件中,draw艺术的完成

在调用draw方法前应规定数据总体赋值实现,绘制专门的学业实际是在- (void)drawRect:(CGRect)rect措施中变成的,所以.h文件中的draw方法只是来调用系统方法的

在.m文件中,draw方法的兑现

- draw { [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; [self setNeedsDisplay];}
- (void)draw {
 [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
 [self setNeedsDisplay];
}

[self setNeedsDisplay];正是来调用drawRect方法的[self.subviews
makeObjectsPerformSelector:@selector(removeFromSuperview)];这一个艺术是用来移除增添到pieChart上的centerView,不然老是重绘时都会再一次增多八个centerView

[self setNeedsDisplay];尽管来调用drawRect方法的

  • 上边正是drawRect办法的兑现

    • 先是要求明确圆的半径,中央点和起初点

    CGFloat min = self.bounds.size.width > self.bounds.size.height ? self.bounds.size.height : self.bounds.size.width;CGPoint center = CGPointMake(self.bounds.size.width * 0.5, self.bounds.size.height * 0.5);CGFloat radius = min * 0.5 - CHART_MARGIN;CGFloat start = 0;CGFloat angle = 0;CGFloat end = start;
    

    CHART_MA汉兰达GIN是本人定义的三个宏,圆不可能让视图的边造成切线,在此作者把CHART_MARGIN设定为60

[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];以此艺术是用来移除增添到pieChart上的centerView,否则老是重绘时都会再次加多3个centerView

上边就是drawRect方法的得以实现

* 根据产品的需求,当请求回来的数据为空时,显示一个纯色的圆,不画指引线,所以在drawRect中分两种情况来实现```objcif (self.dataArray.count == 0) {} else {}```* 当dataArray的长度为0时```objcif (self.dataArray.count == 0) { end = start + M_PI * 2; UIColor *color = COLOR_ARRAY.firstObject; UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:start endAngle:end clockwise:true]; [color set]; //添加一根线到圆心 [path addLineToPoint:center]; [path fill]; }```> COLOR_ARRAY是自己设定的一个宏定义,产品要求的饼图份数是6份,每份颜色一定,所以做一个宏定义存储一下(做成变量都是可以的,看自己代码风格)``` objc#define COLOR_ARRAY @[\

率先必要鲜明圆的半径,中央点和起先点

[UIColor colorWithRed:251/255.0 green:166.9/255.0 blue:96.5/255.0
alpha:1],[UIColor colorWithRed:151.9/255.0 green:188/255.0
blue:95.8/255.0 alpha:1],[UIColor colorWithRed:245/255.0
green:94/255.0 blue:102/255.0 alpha:1],[UIColor colorWithRed:29/255.0
green:140/255.0 blue:140/255.0 alpha:1],[UIColor
colorWithRed:121/255.0 green:113/255.0 blue:199/255.0
alpha:1],[UIColor colorWithRed:16/255.0 green:149/255.0 blue:224/255.0
alpha:1]]“`*新蒲京官方下载 , 当dataArray的尺寸不为0时

CGFloat min = self.bounds.size.width > self.bounds.size.height ? self.bounds.size.height : self.bounds.size.width;
CGPoint center = CGPointMake(self.bounds.size.width * 0.5, self.bounds.size.height * 0.5);
CGFloat radius = min * 0.5 - CHART_MARGIN;
CGFloat start = 0;
CGFloat angle = 0;
CGFloat end = start;
```objcfor (int i = 0; i < self.dataArray.count; i++) { DVFoodPieModel *model = self.dataArray[i]; CGFloat percent = model.rate; UIColor *color = COLOR_ARRAY[i % 6]; start = end; angle = percent * M_PI * 2; end = start + angle; UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:start endAngle:end clockwise:true]; [color set]; //添加一根线到圆心 [path addLineToPoint:center]; [path fill];}```

CHART_MA奥迪Q伍GIN是友善定义的一个宏,圆不可能让视图的边造成切线,在此笔者把CHART_MARGIN设定为60
*
依照产品的急需,当呼吁回来的数额为空时,呈现二个纯色的圆,不画教导线,所以在drawRect中分三种情景来促成

在else中如此做,就能够绘制出各类扇形

```objc
if (self.dataArray.count == 0) {

} else {

}
```
* 当dataArray的长度为0时

```objc
if (self.dataArray.count == 0) {

 end = start + M_PI * 2;

 UIColor *color = COLOR_ARRAY.firstObject;

 UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:start endAngle:end clockwise:true];

 [color set];

 //添加一根线到圆心
 [path addLineToPoint:center];
 [path fill];

}
```
> COLOR_ARRAY是自己设定的一个宏定义,产品要求的饼图份数是6份,每份颜色一定,所以做一个宏定义存储一下(做成变量都是可以的,看自己代码风格)

``` objc
#define COLOR_ARRAY @[\
* 在扇形绘画出来后,添加centerView```objc// 在中心添加labelDVPieCenterView *centerView = [[DVPieCenterView alloc] init];centerView.frame = CGRectMake(0, 0, 80, 80);CGRect frame = centerView.frame;frame.origin = CGPointMake(self.frame.size.width * 0.5 - frame.size.width * 0.5, self.frame.size.height * 0.5 - frame.size.width * 0.5);centerView.frame = frame;centerView.nameLabel.text = self.title;[self addSubview:centerView];```

[UIColor colorWithRed:251/255.0 green:166.9/255.0 blue:96.5/255.0
alpha:1],
[UIColor colorWithRed:151.9/255.0 green:188/255.0 blue:95.8/255.0
alpha:1],
[UIColor colorWithRed:245/255.0 green:94/255.0 blue:102/255.0
alpha:1],
[UIColor colorWithRed:29/255.0 green:140/255.0 blue:140/255.0
alpha:1],
[UIColor colorWithRed:121/255.0 green:113/255.0 blue:199/255.0
alpha:1],
[UIColor colorWithRed:16/255.0 green:149/255.0 blue:224/255.0
alpha:1]
]
“`

  • 绘制指点线,须要在画扇形时就鲜明多少个数据,并遵照那两种多少实行绘图

    • 逐1扇形圆弧的宗旨点
    • 教导线的重大(效果图中有圆点的地点)

    // 获取弧度的中心角度CGFloat radianCenter = (start + end) * 0.5;// 获取指引线的终点CGFloat lineStartX = self.frame.size.width * 0.5 + radius * cos(radianCenter);CGFloat lineStartY = self.frame.size.height * 0.5 + radius * sin(radianCenter);CGPoint point = CGPointMake(lineStartX, lineStartY); 
    

    因为这么些图刚刚做出来时是有臃肿的,按产品必要开始展览改造,所以起的变量名称会微微歧义,不便利改了,作者只得做好注释,大家以注释为准

  • 借使按梯次举行绘图的话,那么很难让指引线的岗位不重叠,所以从中路的三个数量先进行绘图,然后在绘制中间数据两侧的多少

  • 那么,未来内需将地点供给明确的数量依次增加到叁个数组中

* 当dataArray的长短不为0时

例:原数据为@[@1, @2, @3, @4, @5,
@6]画引导线时则要求多少那样来弄@[@3, @2, @1, @4, @5, @6]

```objc

for (int i = 0; i < self.dataArray.count; i++) {
 DVFoodPieModel *model = self.dataArray[i];
 CGFloat percent = model.rate;
 UIColor *color = COLOR_ARRAY[i % 6];
 start = end;
 angle = percent * M_PI * 2;
 end = start + angle;
 UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:start endAngle:end clockwise:true];
 [color set];
 //添加一根线到圆心
 [path addLineToPoint:center];
 [path fill];
}
```
  • 就此for循环中应有改成这几个样子

在else中如此做,就能够绘制出各种扇形

专注,数据变动顺序了今后,绘制时模型数据和颜料数据也亟需更换顺序首先注解五个变量

* 在扇形绘画出来后,添加centerView
```objc
// 在中心添加label
DVPieCenterView *centerView = [[DVPieCenterView alloc] init];
centerView.frame = CGRectMake(0, 0, 80, 80);
CGRect frame = centerView.frame;
frame.origin = CGPointMake(self.frame.size.width * 0.5 - frame.size.width * 0.5, self.frame.size.height * 0.5 - frame.size.width * 0.5);
centerView.frame = frame;
centerView.nameLabel.text = self.title;
[self addSubview:centerView];
```
@interface DVPieChart ()@property (nonatomic, strong) NSMutableArray *modelArray;@property (nonatomic, strong) NSMutableArray *colorArray;@end

相关文章

No Comments, Be The First!
近期评论
    功能
    网站地图xml地图