목표 : 이미지를 드래그하면 배경 뷰를 볼 수 있으므로 희미 해집니다.이미지를 드래그 할 때 알파 값을 변경하는 방법
드래그 시간에 이미지의 알파 값을 늘리거나 줄이는 방법은 무엇입니까?
감사
목표 : 이미지를 드래그하면 배경 뷰를 볼 수 있으므로 희미 해집니다.이미지를 드래그 할 때 알파 값을 변경하는 방법
드래그 시간에 이미지의 알파 값을 늘리거나 줄이는 방법은 무엇입니까?
감사
샘플 코드를 요청하는 것 같습니다. UIImageView의 클래스 하위 클래스를 만들 수 있습니다. 마찬가지로 :
.H
@interface YourImageController : UIImageView
{
CGPoint startLocation;
}
@end
하는 .m
@implementation YourImageController
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
[self setAlpha:x.x];
// Retrieve the touch point
CGPoint pt = [[touches anyObject] locationInView:self];
startLocation = pt;
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self setAlpha:x.x];
CGPoint pt = [[touches anyObject] locationInView:self];
CGFloat dx = pt.x - startLocation.x;
CGFloat dy = pt.y - startLocation.y;
CGPoint newCenter = CGPointMake(self.center.x + dx, self.center.y + dy);
self.center = newCenter;
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self setAlpha:1.0];
}
은 image.alpha
touchesBegan
에를 줄입니다. touchesEnd
로 증가 시키십시오.