-1
A
回答
0
您可以实现视图或视图控制器上的方法
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self];
NSLog(@"location: %@",NSStringFromCGPoint(location));
// Example:
// alpha depends on location.x related to view bounds width
CGFloat alpha = (self.bounds.size.width - location.x)/self.bounds.size.width;
NSLog(@"alpha: %@",@(alpha));
}
在这里你可以检查location.x
或location.y
。
0
尽量做到像以下:
首先连接自来水GestureRecognizer
查看:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourTapMethod:)];
tap.numberOfTapsRequired = 1;
tap.numberOfTouchesRequired = 1;
[imageView addGestureRecognizer:tap];
然后,在手势识别处理程序做你想要什么:
-(void)yourTapMethod{
[UIView animateWithDuration:0.5 animations:^(void){
imageView.alpha = //add any value (like 0.2f);
}
相关问题
- 1. 客观C改变捏手势视图
- 2. ios图像上的文字手势
- 3. 更改子视图的alpha值而不更改父视图的alpha值
- 4. iOS:在子视图内轻扫手势
- 5. 使用UIScrollView更改图像的alpha值
- 6. android图库视图更改alpha值
- 7. 用手势滑动视图
- 8. UIView轻扫手势更改图像
- 9. javascript - 更改图像的alpha值
- 10. 手势在iOS系统子视图和的MKMapView - 基本的iOS
- 11. 如何使用thread.sleep多次更改图像视图的alpha?
- 12. 在列表视图中对图像使用点击手势
- 13. Android手势在图像上
- 14. 带手势的图像 - 手机
- 15. 自定义视图不会用手势
- 16. 用触摸手势滑动视图
- 17. 重叠视图中的ios手势识别器
- 18. 如何跳过顶部视图的手势 - iOS
- 19. iOS中的图像视图
- 20. Xamarin表单地图点击手势IOS
- 21. 将视图更改为刷卡手势上的一个圆圈,iOS,Swift
- 22. 使用滑动手势更改视图控制器
- 23. WPF图像划像以改变iOS中的图像
- 24. 更改UISlider的跟踪图像的alpha?
- 25. iOS:手势在子视图不被识别
- 26. 潘姿手势不传播到子视图(iOS)
- 27. iOS装置:通过手势视图下方
- 28. 如何在ios中给定手势后保存图像
- 29. 实现图像的手势:用捏合手势的UIImageView模式冲突
- 30. 动态改变图像视图内的图像
我知道如何将手势应用于视图,但我想更改图像视图的alpha值,就像我们使用滑块更改一样。在我的情况下,我不想使用滑块那 –
看到更新的答案@Bhagyashreemahajan –
你有没有看到应用Prisma?我想要像图像视图手势那样更改alpha。 –