ifish/Ifish/controllers/HotBar/Views/IfishChatView.m

105 lines
2.6 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// IfishChatView.m
// Ifish
//
// Created by 罗艺 on 2018/8/27.
// Copyright © 2018年 lianlian. All rights reserved.
//
#import "IfishChatView.h"
@interface IfishChatView()
@property(nonatomic,strong)NSMutableArray*line1;
@property(nonatomic,strong)NSMutableArray*line2;
@end
@implementation IfishChatView
-(NSArray *)line1{
if (_line1==nil) {
_line1=[NSMutableArray array];
for (int i=0; i<50; i++) {
CGFloat x=10*(i+1);
CGPoint p1=CGPointMake(x, x);
[_line1 addObject:NSStringFromCGPoint(p1)];
}
}
return _line1;
}
-(NSArray *)line2{
if (_line2==nil) {
_line2=[NSMutableArray array];
for (int i=0; i<50; i++) {
CGFloat x=10*(i+1);
CGFloat y=sin(x)*10+5;
CGPoint p1=CGPointMake(x, y);
[_line2 addObject:NSStringFromCGPoint(p1)];
}
}
return _line2;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色
UIBezierPath* path = [UIBezierPath bezierPath];
path.lineWidth = 1.0;
path.lineCapStyle = kCGLineCapRound; //线条拐角
path.lineJoinStyle = kCGLineJoinRound; //终点处理
[path moveToPoint:CGPointMake(0.0, 0.0)];//起点
// Draw the lines
for (int i=0; i<self.line1.count; i++) {
NSString* p=self.line1[i];
[path addLineToPoint:CGPointFromString(p)];
}
// [path closePath];//第五条线通过调用closePath方法得到的
// [path stroke];//Draws line 根据坐标点连线
[path stroke];//颜色填充
UIColor *color1 = [UIColor blueColor];
[color1 set]; //设置线条颜色
UIBezierPath* path1 = [UIBezierPath bezierPath];
path1.lineWidth = 1.0;
path1.lineCapStyle = kCGLineCapRound; //线条拐角
path1.lineJoinStyle = kCGLineJoinRound; //终点处理
[path1 moveToPoint:CGPointMake(0.0, 100.0)];//起点
// Draw the lines
for (int i=0; i<self.line2.count; i++) {
NSString* p=self.line2[i];
[path1 addLineToPoint:CGPointFromString(p)];
}
// [path closePath];//第五条线通过调用closePath方法得到的
// [path stroke];//Draws line 根据坐标点连线
CGFloat dashPattern[] = {3,1};// 3实线1空白
[path1 setLineDash:dashPattern count:1 phase:1];
[path1 stroke];//颜色填充
}
@end