zoukankan      html  css  js  c++  java
  • iOS简单的画线(UIImageVIew方式)

    #import <UIKit/UIKit.h>
    
    @interface ViewController : UIViewController
    {
        UIImageView *mImageView;
    }
    
    @end
    

      

    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    	mImageView = [[UIImageView alloc] initWithFrame:self.view.frame];
        mImageView.backgroundColor = [UIColor grayColor];
        [self.view addSubview:mImageView];
        UIGraphicsBeginImageContext(mImageView.frame.size);
        [mImageView.image drawInRect:CGRectMake(0, 0, mImageView.frame.size.width, mImageView.frame.size.height)];
        CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
        CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 15);
        CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);
        CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor blueColor] CGColor]);
        CGContextBeginPath(UIGraphicsGetCurrentContext());
        CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 100, 100);
        CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), 200, 200);
        CGContextStrokePath(UIGraphicsGetCurrentContext());
        mImageView.image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }
    
    @end
    

      

     

  • 相关阅读:
    Typora的使用
    selenium中webdriver提供的八大定位元素方法
    JAVA的Data和Timestamp的相互转换
    Jmeter设置参数作为断言依据
    Springboot +Poi 导入Excel表格
    window.location.reload();
    带参数的链接跳转
    Layui结束时间不能小于开始时间
    后台返回数据渲染Layui表格
    Layui中layedit模板的使用
  • 原文地址:https://www.cnblogs.com/greywolf/p/2617055.html
Copyright © 2011-2022 走看看