1 parent
e372df28dc
commit
8d26ed38d7
3 files changed
+36
-7
No files matched your search
@@ -474,7 +474,8 @@ self.view.frame.size.width * 0.3 - 36.0 * 0.7, self.view.frame.size.height)];
|
||||
}
|
||||
|
||||
[button addTarget:self action:@selector(executebtn_down:) forControlEvents:UIControlEventTouchDown];
|
||||
[button addTarget:self action:@selector(executebtn_up:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
|
||||
[button addTarget:self action:@selector(executebtn_up_inside:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[button addTarget:self action:@selector(executebtn_up_outside:) forControlEvents:UIControlEventTouchUpOutside];
|
||||
|
||||
if (isSwipeable) {
|
||||
UIPanGestureRecognizer *panRecognizerButton = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(executebtn_swipe:)];
|
||||
@@ -964,7 +965,9 @@ CallbackBridge_nativeSendKey(keycode, 0, held, 0);
|
||||
|
||||
- (void)executebtn_down:(ControlButton *)sender
|
||||
{
|
||||
[self executebtn:sender withAction:ACTION_DOWN];
|
||||
if (sender.savedBackgroundColor == nil) {
|
||||
[self executebtn:sender withAction:ACTION_DOWN];
|
||||
}
|
||||
if ([self.swipeableButtons containsObject:sender]) {
|
||||
self.swipingButton = sender;
|
||||
}
|
||||
@@ -974,12 +977,12 @@ CallbackBridge_nativeSendKey(keycode, 0, held, 0);
|
||||
{
|
||||
CGPoint location = [sender locationInView:self.rootView];
|
||||
if (sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateEnded) {
|
||||
[self executebtn_up:self.swipingButton];
|
||||
[self executebtn_up:self.swipingButton isOutside:NO];
|
||||
return;
|
||||
}
|
||||
for (ControlButton *button in self.swipeableButtons) {
|
||||
if (CGRectContainsPoint(button.frame, location) && (ControlButton *)self.swipingButton != button) {
|
||||
[self executebtn:self.swipingButton withAction:ACTION_UP];
|
||||
[self executebtn_up:self.swipingButton isOutside:NO];
|
||||
self.swipingButton = (ControlButton *)button;
|
||||
[self executebtn:self.swipingButton withAction:ACTION_DOWN];
|
||||
break;
|
||||
@@ -987,16 +990,38 @@ CallbackBridge_nativeSendKey(keycode, 0, held, 0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)executebtn_up:(ControlButton *)sender
|
||||
- (void)executebtn_up:(ControlButton *)sender isOutside:(BOOL)isOutside
|
||||
{
|
||||
if (self.swipingButton == sender) {
|
||||
[self executebtn:self.swipingButton withAction:ACTION_UP];
|
||||
self.swipingButton = nil;
|
||||
} else if (sender.savedBackgroundColor == nil) {
|
||||
[self executebtn:sender withAction:ACTION_UP];
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOutside || sender.savedBackgroundColor == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
sender.isToggleOn = !sender.isToggleOn;
|
||||
if (sender.isToggleOn) {
|
||||
sender.backgroundColor = [self.view.tintColor colorWithAlphaComponent:CGColorGetAlpha(sender.savedBackgroundColor.CGColor)];
|
||||
[self executebtn:sender withAction:ACTION_DOWN];
|
||||
} else {
|
||||
sender.backgroundColor = sender.savedBackgroundColor;
|
||||
[self executebtn:sender withAction:ACTION_UP];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)executebtn_up_inside:(ControlButton *)sender {
|
||||
[self executebtn_up:sender isOutside:NO];
|
||||
}
|
||||
|
||||
- (void)executebtn_up_outside:(ControlButton *)sender {
|
||||
[self executebtn_up:sender isOutside:YES];
|
||||
}
|
||||
|
||||
- (void)executebtn_special_togglebtn:(int)held {
|
||||
if (held == 0) {
|
||||
currentVisibility = !currentVisibility;
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
@interface ControlButton : UIButton {
|
||||
}
|
||||
|
||||
@property BOOL canBeHidden;
|
||||
@property BOOL canBeHidden, isToggleOn;
|
||||
@property(nonatomic, strong) NSMutableDictionary* properties;
|
||||
@property UIColor* savedBackgroundColor;
|
||||
|
||||
+ (id)buttonWithProperties:(NSMutableDictionary *)propArray;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
+ (id)buttonWithProperties:(NSMutableDictionary *)propArray {
|
||||
//NSLog(@"DBG button prop = %@", propArray);
|
||||
ControlButton *instance = [self buttonWithType:UIButtonTypeRoundedRect];
|
||||
ControlButton *instance = [self buttonWithType:UIButtonTypeSystem];
|
||||
instance.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
instance.tintColor = [UIColor whiteColor];
|
||||
instance.titleLabel.adjustsFontSizeToFitWidth = YES;
|
||||
@@ -172,6 +172,9 @@
|
||||
self.alpha = [self.properties[@"opacity"] floatValue];
|
||||
self.alpha = MAX(self.alpha, isControlModifiable ? 0.1 : 0.01);
|
||||
self.backgroundColor = convertARGB2UIColor(propBackgroundColor);
|
||||
if ([self.properties[@"isToggle"] boolValue]) {
|
||||
self.savedBackgroundColor = self.backgroundColor;
|
||||
}
|
||||
|
||||
self.layer.borderColor = [convertARGB2UIColor(propStrokeColor) CGColor];
|
||||
self.layer.cornerRadius = MIN(self.frame.size.width, self.frame.size.height) / 200.0 * propCornerRadius;
|
||||
|
||||
Reference in new issue
Block a user