画图

//
//  MyView.h
//  AppUI组件学习
//
//  Created by 麦子 on 15/6/24.
//  Copyright (c) 2015年 麦子. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MyView : UIView

@property(nonatomic,assign) CGPoint point;

@end
//
//  MyView.m
//  AppUI组件学习
//
//  Created by 麦子 on 15/6/24.
//  Copyright (c) 2015年 麦子. All rights reserved.
//

#import "MyView.h"

@implementation MyView

@synthesize point;

- (instancetype)initWithFrame:(CGRect)frameA{

    self = [super initWithFrame:frameA];
    if (self) {
        self.backgroundColor = [UIColor orangeColor];
        point.x = 10;
        point.y = 300;
    }
    return self;
}
// 画图
- (void)drawRect:(CGRect)rect{

//    point.x+=5;
    point.y+=5;
    
    // 获取上下文, 获取画布
    CGContextRef context = UIGraphicsGetCurrentContext();
    // 画线 起点
    CGContextMoveToPoint(context, 0, 0);
    // 终点
    CGContextAddLineToPoint(context, 200,200);
    // 线涂色
    CGContextStrokePath(context);
    
    
    // 画矩形
    CGRect cgrect = CGRectMake(100, 100, 200, 200);
    CGContextAddRect(context, cgrect);
    CGContextStrokePath(context);
    
    CGRect rect2 = CGRectMake(120, 120, 200, 200);
    CGContextStrokeRect(context, rect2);
    
    // 实心矩形
    CGContextFillRect(context, rect2);
    
    // 画圆
    CGContextStrokeEllipseInRect(context, CGRectMake(10, 200, 100, 100));
    
    // 实心圆
    CGContextFillEllipseInRect(context, CGRectMake(point.x, point.y, 100, 100));
    
    // 画文字
    NSString *str = @"see you !";
    [str drawAtPoint:CGPointMake(10, 400) withAttributes:nil];
    
    
    // 画图片
    UIImage *image = [UIImage imageNamed:@"tupian5.jpg"];
    [image drawAtPoint:CGPointMake(10, 450)];
    
    
}


@end

//
//  DrawViewController.m
//  AppUI组件学习
//
//  Created by 麦子 on 15/6/24.
//  Copyright (c) 2015年 麦子. All rights reserved.
//

#import "DrawViewController.h"
#import "MyView.h"

@interface DrawViewController ()

@end

@implementation DrawViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     self.title = @"画视图";
    MyView *view = [[MyView alloc] init];
    self.view = view;
    
    [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(timeBusiness:) userInfo:nil repeats:YES];
}


- (void)timeBusiness:(NSTimer *)timer{

   
    [self.view setNeedsDisplay];
    
     // 干掉定时器
//    [timer invalidate];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Draw软件所达到的功能 开发绘制直线(Line)功能:两点画线(1)、角度画线(2)、XY画线(3)、画垂线(4)、点距画线(5)、相切圆(弧)画线(6) 开发绘制圆(Cercle)功能:半径圆心画圆(1)、三点画圆(2)、点距画圆(3)、半径圆心值画圆(4)、相切直线/圆(弧)画圆(5)、相切两线画圆(6) 开发绘制多边形(Polygon)功能:画正多边形(1)、画矩形(2),正多边形包括三角形、正方形、五边形、六边形、七边形、八边形 开发绘制弧(Arc)功能:弧心半径值起始角度弧度画弧线(1)、弧心半径弧度值画弧线(2)、相切图形(直线,圆,弧)画弧线(3) 开发绘制文本(Text)功能:绘制文本(1)、字体大小(2) 界面及文本字体风格设置:普通(1),粗体(2),斜体(3),斜体加粗(4),一共四种样式。 保存及打开状态菜单:保存当前绘制环境或打开已存在的绘制环境。 保存制图:根据当前水平和垂直滚动条动态生成所绘制图形,保存成图片格式(bmp,jpg(默认),png,tiff,gif,pcx,tga,exif,svg,psd,cdr,pcd,ufo,eps,ai,raw,WFM) 清除全部:清除屏幕中全部图形,不包括集合中内容。 颜色选择器/背景颜色选择器:调出Java中已封装的颜色选择器(JColorChooser类的createDialog(略)方法,用于设置线条颜色/背景颜色)。 线条宽度:弹出输入对话框,用于设置线条宽度。 灵敏度调节:弹出输入对话框,用于设置采集点和图形的灵敏程度。 撤销上一步/前进下一步:用于当操作错误,撤销此步操作/当撤销错误,回到撤销之前操作。 刷新:用于刷新当前绘图。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值