iOS13 compatibility: apply background for each widget in widget panel
This commit is contained in:
1 parent
1046cfe9a0
commit
25073803ba
2 files changed
+40
-38
No files matched your search
+38
-37
@@ -621,14 +621,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)autoFitView:(UIView* )view{
|
- (void)autoFitStack:(UIStackView* )stack{
|
||||||
CGSize fittingSize = [view systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
|
CGSize fittingSize = [stack systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
|
||||||
CGRect newFrame = view.frame;
|
CGRect newFrame = stack.frame;
|
||||||
newFrame.size = fittingSize;
|
newFrame.size = fittingSize;
|
||||||
view.frame = newFrame;
|
stack.frame = newFrame;
|
||||||
[self updateClippedMaskForView:view];
|
[self updateClippedMaskForView:stack];
|
||||||
if (@available(iOS 14, *)) nil;
|
if (@available(iOS 14, *)) nil;
|
||||||
else [self applyBackgroundForiOS13:view];
|
else [self applyShadowForiOS13:stack];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)enableCommonWidgetTools{
|
- (void)enableCommonWidgetTools{
|
||||||
@@ -683,7 +683,7 @@
|
|||||||
self.mouseDownButtonStack.hidden = !([selectedWidgetView.cmdString containsString:@"MOUSEPAD"] && selectedWidgetView.widgetType == WidgetTypeEnumTouchPad);
|
self.mouseDownButtonStack.hidden = !([selectedWidgetView.cmdString containsString:@"MOUSEPAD"] && selectedWidgetView.widgetType == WidgetTypeEnumTouchPad);
|
||||||
self.decelerationRateStack.hidden = !([selectedWidgetView.cmdString containsString:@"TRACKBALL"] && selectedWidgetView.widgetType == WidgetTypeEnumTouchPad);
|
self.decelerationRateStack.hidden = !([selectedWidgetView.cmdString containsString:@"TRACKBALL"] && selectedWidgetView.widgetType == WidgetTypeEnumTouchPad);
|
||||||
|
|
||||||
[self autoFitView:self.widgetPanelStack];
|
[self autoFitStack:self.widgetPanelStack];
|
||||||
|
|
||||||
if(showSensitivityFactorStack){
|
if(showSensitivityFactorStack){
|
||||||
[self.sensitivityXSlider setValue:self->selectedWidgetView.sensitivityFactorX];
|
[self.sensitivityXSlider setValue:self->selectedWidgetView.sensitivityFactorX];
|
||||||
@@ -725,7 +725,7 @@
|
|||||||
self.vibrationStyleStack.hidden =
|
self.vibrationStyleStack.hidden =
|
||||||
[widgetView.cmdString containsString:@"MOUSEPAD"] ||
|
[widgetView.cmdString containsString:@"MOUSEPAD"] ||
|
||||||
[widgetView.cmdString containsString:@"TRACKBALL"];
|
[widgetView.cmdString containsString:@"TRACKBALL"];
|
||||||
[self autoFitView:self.widgetPanelStack];
|
[self autoFitStack:self.widgetPanelStack];
|
||||||
self.vibrationStyleSelector.selectedSegmentIndex = self->selectedWidgetView.vibrationStyle;
|
self.vibrationStyleSelector.selectedSegmentIndex = self->selectedWidgetView.vibrationStyle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -770,7 +770,7 @@
|
|||||||
NSNumber *style = [OnScreenControls.layerVibrationStyleDic objectForKey:selectedControllerLayer.name];
|
NSNumber *style = [OnScreenControls.layerVibrationStyleDic objectForKey:selectedControllerLayer.name];
|
||||||
self.vibrationStyleSelector.selectedSegmentIndex = [style unsignedCharValue];
|
self.vibrationStyleSelector.selectedSegmentIndex = [style unsignedCharValue];
|
||||||
}
|
}
|
||||||
[self autoFitView:_widgetPanelStack];
|
[self autoFitStack:_widgetPanelStack];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)widgetSizeSliderMoved:(UISlider* )sender{
|
- (void)widgetSizeSliderMoved:(UISlider* )sender{
|
||||||
@@ -996,7 +996,7 @@
|
|||||||
self.widgetPanelStack.frame = frame;
|
self.widgetPanelStack.frame = frame;
|
||||||
|
|
||||||
|
|
||||||
[self autoFitView:self.widgetPanelStack];
|
[self autoFitStack:self.widgetPanelStack];
|
||||||
|
|
||||||
if([self isIPhone]) {
|
if([self isIPhone]) {
|
||||||
for(UIView* view in _widgetPanelStack.arrangedSubviews){
|
for(UIView* view in _widgetPanelStack.arrangedSubviews){
|
||||||
@@ -1021,35 +1021,36 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applyBackgroundForiOS13:(UIView* )view {
|
- (void)applyShadowForiOS13:(UIStackView* )stack {
|
||||||
view.backgroundColor = [UIColor clearColor];
|
stack.backgroundColor = [UIColor clearColor];
|
||||||
UIView *backgroundView;
|
|
||||||
for(UIView* subview in view.subviews){
|
for(UIView* view in stack.arrangedSubviews){
|
||||||
if([subview.accessibilityIdentifier isEqualToString:@"iOS13Background"]){
|
if([view isKindOfClass:[UIStackView class]]){
|
||||||
backgroundView = subview;
|
UIStackView* subStack = (UIStackView* )view;
|
||||||
break;
|
for(UIView* view in subStack.arrangedSubviews){
|
||||||
|
if([view isKindOfClass:[UILabel class]]){
|
||||||
|
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
|
||||||
|
view.layer.cornerRadius = 6;
|
||||||
|
view.clipsToBounds = YES;
|
||||||
|
UILabel* label = (UILabel* )view;
|
||||||
|
label.textAlignment = NSTextAlignmentCenter;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
view.tintColor= [UIColor systemTealColor];
|
||||||
|
view.layer.shadowColor = [[UIColor blackColor] colorWithAlphaComponent:0.9].CGColor;
|
||||||
|
//view.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||||
|
view.layer.shadowOffset = CGSizeMake(1, 1);
|
||||||
|
view.layer.shadowOpacity = 1;
|
||||||
|
view.layer.shadowRadius = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
view.layer.cornerRadius = 10;
|
||||||
|
view.clipsToBounds = YES;
|
||||||
|
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!backgroundView){
|
|
||||||
backgroundView = [[UIView alloc] init];
|
|
||||||
backgroundView.accessibilityIdentifier = @"iOS13Background";
|
|
||||||
}
|
|
||||||
|
|
||||||
backgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
|
|
||||||
backgroundView.layer.cornerRadius = 16;
|
|
||||||
backgroundView.clipsToBounds = YES;
|
|
||||||
backgroundView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
||||||
backgroundView.userInteractionEnabled = NO;
|
|
||||||
|
|
||||||
[view insertSubview:backgroundView atIndex:0];
|
|
||||||
|
|
||||||
// UIEdgeInsets m = self.layoutMargins;
|
|
||||||
[NSLayoutConstraint activateConstraints:@[
|
|
||||||
[backgroundView.leadingAnchor constraintEqualToAnchor:view.leadingAnchor constant:0],
|
|
||||||
[backgroundView.trailingAnchor constraintEqualToAnchor:view.trailingAnchor constant:0],
|
|
||||||
[backgroundView.topAnchor constraintEqualToAnchor:view.topAnchor constant:0],
|
|
||||||
[backgroundView.bottomAnchor constraintEqualToAnchor:view.bottomAnchor constant:0]
|
|
||||||
]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1788,9 +1788,10 @@ static NSMutableSet* hostList;
|
|||||||
[super viewWillAppear:NO];
|
[super viewWillAppear:NO];
|
||||||
|
|
||||||
/* this makes background color works*/
|
/* this makes background color works*/
|
||||||
|
/*
|
||||||
for (UIView *subview in self.view.subviews) {
|
for (UIView *subview in self.view.subviews) {
|
||||||
[subview removeFromSuperview]; // 暂时移除所有子视图
|
[subview removeFromSuperview]; // 暂时移除所有子视图
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
// We can get here on home press while streaming
|
// We can get here on home press while streaming
|
||||||
|
|||||||
Reference in new issue
Block a user