ユーザーが画面上で指を動かして UIImageView を描画するようにします。ユーザーが指を右に動かすと、幅が変化します。これは私のコードです:
これは drawrect メソッドで:
if (touchmoved)
{
rectImage = [[UIImageView alloc] initWithFrame:CGRectMake(startPoint.x, startPoint.y, (movePoint.x-startPoint.x), (movePoint.y-startPoint.y))];
rectImage.backgroundColor = [UIColor clearColor];
rectImage.layer.borderColor = [UIColor blackColor].CGColor;
rectImage.layer.borderWidth = 2.0;
[self addSubview:rectImage];
touchmoved = NO;
}
ここでは、touchedMoved メソッドで touchmoved が YES に設定されています。
if ((movePoint.x > startPoint.x)&&(movePoint.y >startPoint.y)) //startPoint in the locationinView point in the touchesBegan.
{
touchBegan = YES;
}
シミュレーターで実行して指を動かすと、次のようになります。
なにが問題ですか?