Fix overlays not being affected by button press and spinner eating touch events

This commit is contained in:
Cameron Gutman
2019-09-01 12:15:26 -07:00
parent 49fc10191c
commit de2a5d3cd7

View File

@@ -47,6 +47,9 @@ static const int LABEL_DY = 20;
_hostButton.layer.shadowColor = [[UIColor blackColor] CGColor];
_hostButton.layer.shadowOffset = CGSizeMake(5,8);
_hostButton.layer.shadowOpacity = 0.3;
[_hostButton addTarget:self action:@selector(hostButtonSelected:) forControlEvents:UIControlEventTouchDown];
[_hostButton addTarget:self action:@selector(hostButtonDeselected:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchCancel | UIControlEventTouchDragExit];
_hostLabel = [[UILabel alloc] init];
_hostLabel.textColor = [UIColor whiteColor];
@@ -54,6 +57,7 @@ static const int LABEL_DY = 20;
_hostOverlay = [[UIImageView alloc] initWithFrame:CGRectMake(_hostButton.frame.size.width / 3, _hostButton.frame.size.height / 4, _hostButton.frame.size.width / 3, _hostButton.frame.size.height / 3)];
_hostSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[_hostSpinner setFrame:_hostOverlay.frame];
_hostSpinner.userInteractionEnabled = NO;
_hostSpinner.hidesWhenStopped = YES;
[self addSubview:_hostButton];
@@ -64,6 +68,15 @@ static const int LABEL_DY = 20;
return self;
}
- (void) hostButtonSelected:(id)sender {
_hostSpinner.layer.opacity = 0.5f;
_hostOverlay.layer.opacity = 0.5f;
}
- (void) hostButtonDeselected:(id)sender {
_hostSpinner.layer.opacity = 1.0f;
_hostOverlay.layer.opacity = 1.0f;
}
- (id) initForAddWithCallback:(id<HostCallback>)callback {
self = [self init];
_callback = callback;