-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。 –