UIView 내에서 "Flood Fill"구현을 직접 작성하려고합니다. 모든 것이 잘되고 있지만 UIImageView 또는 UIView에서 특정 지점/픽셀의 색상을 변경하는 방법을 알 수 없습니다.UIView 또는 UIImageView에서 점의 색상을 어떻게 바꿀 수 있습니까?
UIView 내에서 점이나 픽셀의 색상을 변경하려면 어떻게해야합니까?
편집 : 여기
내 시나리오 : 터치 이벤트에
1 :
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint loc = [touch locationInView:_image];
UIColor *mycol=[self getPixelColorAtLocation:loc];
if (mycondition) {
_mylayer->point_=loc;
_mylayer->color_=mycol;
[_mylayer setNeedsDisplay];
}
}
그리기 RECT 내 사용자 지정에 UIView
- (void)drawRect:(CGRect)rect {
if (point_.x>0) {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, color_.CGColor);
CGContextFillRect(context, CGRectMake(point_.x,point_.y, 1.0, 1.0));
}
}
내 요점은 지금 "내가 012라고 할 때마다배치 된 점 (새 색)이 제거되고 새 점 (단지 1 점)이 나타납니다.
어떤 생각
이미지 뷰 상단에 맞춤보기를 추가 할 수 있습니다. – Felix