目前我是这么做的:
- (void )loadView
{
self.view = [UIView new];
UIView *shareView = [UIView new];
[self.view addSubview:shareView];
shareView.backgroundColor = [UIColor colorWithRGBA:0xEEEEEEFF];
shareView.userInteractionEnabled = YES;
UITapGestureRecognizer *gestureForShare = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector (shareViewClicked:)];
gestureForShare.numberOfTapsRequired = 1;
[shareView addGestureRecognizer:gestureForShare];
}
- (void )shareViewClicked:(UITapGestureRecognizer *)gestureRecognizer
{
gestureRecognizer.view.backgroundColor = [UIColor colorWithRGBA:0xDDDDDDFF];
// 背景变暗持续 0.2s 后变回来
dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(0.2 * NSEC_PER_SEC )), dispatch_get_main_queue (), ^{
gestureRecognizer.view.backgroundColor = [UIColor colorWithRGBA:0xEEEEEEFF];
});
}
效果虽然实现了,但总感觉别扭,不知道大家是怎样做的...请教下。