Similar to the WeChat voice on the slide cancel, the effect of the decline to achieve

Today, on Friday, this week’s work was finally completed. In the morning to the company, the past few months to do things finishing, write a few blog. The
was the voice dictation custom UI Xunfei, here to talk about the concrete realization of some function in the interaction.
similar to WeChat voice on the slide to cancel, send down. You can use gestures to do, you can also use the button to do the click event. I am here to introduce the button click event, because the individual feels gesture is good, but if the current page has other gestures, it is inevitable there will be conflict, so use the button to achieve is the most simple.
code is as follows:

UIButton *btnSpeak = [[UIButton alloc]init]; [voiceView addSubview:btnSpeak]; btnSpeak.backgroundColor = [UIColor whiteColor]; [btnSpeak setTitle:@ forState:UIControlStateNormal]; "hold to" [btnSpeak setTitle:@ "forState: UIControlStateHighlighted] [btnSpeak release end"; setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; btnSpeak.titleLabel.font = btnSpeak.layer.cornerRadius=5; [UIFont systemFontOfSize:17]; btnSpeak.layer.borderColor=[UIColor colorWithRed:230/ 255 green:233/255.0 blue:231/255.0 alpha:1.0].CGColor; btnSpeak.layer.borderWidth=1; btnSpeak.layer.masksToBounds=YES; [btnSpeak mas_makeConstraints:^ (MASConstraintMaker *make) {make.centerY.equalTo (voiceView) Make.left.equalTo (voiceView);.Offset (15); make.height.equalTo (@46); make.width.equalTo (@ (ScreenW-65));}]; UIButton *keyBoardBtn = [[UIButton alloc]init]; [voiceView addSubview:keyBoardBtn]; [keyBoardBtn setImage:[UIImage imageNamed:@ forState:UIControlStateNormal] [keyBoardBtn "keyBoard"]; mas_makeConstraints:^ (MASConstraintMaker *make) {make.left.equalTo (btnSpeak.mas_right); make.right.equalTo (voiceView; make.centerY.equalTo (voiceView)); make.height.equalTo (voiceView);}]; / / add a click event to start listening to the voice of a user / / [btnSpeak addTarget:self action:@selector (touchSpeak:) forControlEvents:UIControlEventTouchDown]; / / to stop listening And handle user input [btnSpeak addTarget:self action:@selector forControlEvents:UIControlEventTouchUpInside] (stopSpeak:); / / cancel this time monitoring [btnSpeak addTarget:self action:@selector (cancelSpeak:) forControlEvents: UIControlEventTouchUpOutside UIControlEventTouchCancel] |; / / display plans to remove animation [btnSpeak (remindDragExit:) addTarget:self action:@selector forControlEvents:UIControlEventTouchDragExit]; / / send [btnSpeak addTarget:self animation to show a drop of action:@selector (remindDragEnter:) forControlEvents:UIControlEventTouchDragEnter];

The idea is to understand all the click event UIButton and the state of the performance to come out of the perfect use.