一次两个视图中的绘制线

时间:2012-11-05 12:02:11

标签: iphone objective-c ipad

我正在做一个应用程序,我需要在一个视图中绘制线条,并自动显示在另一个视图中。任何帮助将不胜感激..

我试过了..

- (void)viewDidLoad
{
[super viewDidLoad];
slv = [[SmoothLineView alloc] initWithFrame:CGRectMake(DrawingView.bounds.origin.x, DrawingView.bounds.origin.y + 42, DrawingView.bounds.size.width, DrawingView.bounds.size.height - 42)];
slv.delegate = self;
[DrawingView addSubview:slv];
}


-(IBAction)btnAnotherView:(UIButton *)sender
{
[zoomingTypingView setUserInteractionEnabled:YES];
if(sender.tag == 123)
{
    [self.view setBackgroundColor:[UIColor colorWithWhite:0.500 alpha:1.000]];
    [UIView animateWithDuration:0.5
                          delay:0.1
                        options:UIViewAnimationTransitionCurlUp
                     animations:^{
                         //animation code
                         zoomingTypingView.frame = CGRectMake(0, 549, 768, 451);

                     } completion:^(BOOL finished) {


                     }];       
    CGRect imageFrame = CGRectMake(50, 50, 220, 120);
    ResizableView = [[SPUserResizableView alloc] initWithFrame:imageFrame];
    CGRect gripFrame = CGRectMake(50,50, 220,120);
    UIView *zoom = [[UIView alloc]initWithFrame:gripFrame];
    UIScrollView *zoomscroll = [[UIScrollView alloc]initWithFrame:gripFrame];
    [zoomscroll setZoomScale:32.0];
    [zoomscroll setMaximumZoomScale:32.0];
    [zoom addSubview:zoomscroll];
    [ResizableView setContentView:zoom];
    ResizableView.delegate = self;
    [DrawingView addSubview:ResizableView];
    sender.tag = 246;
}
else
{
    [UIView animateWithDuration:0.5
                          delay:0.1
                        options:UIViewAnimationTransitionCurlUp
                     animations:^{
                         //animation code
                         zoomingTypingView.frame = CGRectMake(0, 999, 768, 451);

                     } completion:^(BOOL finished) {
                        [self.view setBackgroundColor:[UIColor whiteColor]];
                     }];
    [ResizableView removeFromSuperview];
    [DrawingView addSubview:slv1];
    sender.tag = 123;
}

}

enter image description here

在上面的图像中,WhiteColored View是新视图,如果我绘制的whiteColoredView应该反映在两个视图中。

您可以通过查看NOTE TAKER HD APP获得更多想法。

http://www.youtube.com/watch?v=FdGDnUKZcMM

1 个答案:

答案 0 :(得分:0)

如果您定义了两个视图:

@property(nonatomic) UIView *view1;
@property(nonatomic) UIView *view2;

而不是做self.view,你可以让函数为一个视图做绘图:

-(void)drawView:(UIView*)view{
  //your drawing code here
}

只需通过不同的视图两次调用相同的函数。

相关问题