• 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
    

      

     

  • 相关阅读:
    javascript执行上下文
    javascript深浅拷贝
    javascript模块化
    javascript类型转换
    闭包
    通过插槽分发内容
    组件上使用v-model
    Vue $emit $event 传值(子to父)
    Vue Prop属性(父to子)
    Vue组件全局/局部注册
  • 原文地址:https://www.cnblogs.com/greywolf/p/2617055.html
Copyright © 2020-2023  润新知