没有在UIView上调用drawRect

时间:2017-12-03 05:27:22

标签: ios objective-c

我已经在我的View Controller中添加了一个UIView。我将其子类设置为newDrawingView.h文件。

//
//  newDrawingView.m
//  slate
//
//  Created by Monica Kachlon on 12/2/17.
//  Copyright © 2017 ma. All rights reserved.
//

#import "newDrawingView.h"

@implementation newDrawingView
UIBezierPath *newPath;
CAShapeLayer * layerStyle;

- (void)startTouch:(CGPoint)point;
{
    [newPath moveToPoint:point];
}

- (void)drawRect:(CGRect)rect {
    NSLog(@"DRAWING");
}

- (void)drawShape:(CGPoint)point
{
    [newPath addLineToPoint: point]; // (4)
    [self setNeedsDisplay];
}

- (void)endTouch:(CGPoint)point {
    [newPath removeAllPoints];
}

@end

我设法处理startTouch,drawShape和endTouch。但是,当我调用self setNeedsDisplay时 - 我的drawRect不会被调用..

0 个答案:

没有答案