Untitled

 avatar
unknown
plain_text
2 years ago
4.3 kB
3
Indexable
-(void)updateOrientation {
    
    if(self.frontView) {
//        if(self.isLandscape == TRUE) {
//            [self.frontView viewWithTag:132].hidden = NO;
//            [self.frontView viewWithTag:13].hidden = YES;
//        }else {
//            [self.frontView viewWithTag:132].hidden = YES;
//            [self.frontView viewWithTag:13].hidden = NO;
//        }
//
//        UIView *landscapeView = ((UIView*)[self.frontView viewWithTag:132]);//Add Landscape UI (UIStackView*)
//        UIView *portraitView = ((UIView*)[self.frontView viewWithTag:13]);//Add Landscape UI (UIStackView*)
        
        
        if(self.isLandscape == YES) {
            AppDelegate *appdeleg = (AppDelegate *)[[UIApplication sharedApplication] delegate];
            UIStackView *stackview = (UIStackView*)[self.frontView viewWithTag:200];
            [stackview setAxis:UILayoutConstraintAxisVertical];
            
            [self.frontView viewWithTag:13].translatesAutoresizingMaskIntoConstraints = TRUE;
    //
            CGRect frame1 = [UIScreen mainScreen].bounds;
            NSLog(@"bottom frame: %@",NSStringFromCGRect(frame1));
            //Tag New
            if (self.isLandscapeRight) {
                frame1.origin.x = [UIScreen mainScreen].bounds.size.width - 95;//130//- appdeleg.window.safeAreaInsets.right
                NSLog(@"Right");
            }else {
                frame1.origin.x = [UIScreen mainScreen].bounds.size.width - 95 - appdeleg.window.safeAreaInsets.right;//130//- appdeleg.window.safeAreaInsets.right
                NSLog(@"left");
            }
            //
            //frame1.origin.x = [UIScreen mainScreen].bounds.size.width - 130;
            
            frame1.size.height = [UIScreen mainScreen].bounds.size.height;
            frame1.size.width = 95;
            NSLog(@"After bottom frame: %@",NSStringFromCGRect(frame1));
            [[self.frontView viewWithTag:13] setFrame:frame1];
            
            
            [self.frontView viewWithTag:4].translatesAutoresizingMaskIntoConstraints = TRUE;
            UIButton *tagButton = (UIButton*)[self.frontView viewWithTag:4];
            CGRect tagFrame = tagButton.bounds;
//
//            tagFrame.origin.y =  30;
//            tagFrame.origin.x =  ([UIScreen mainScreen].bounds.size.width / 2) - 15;
//            [tagButton setFrame:tagFrame];
            
            //Tag New
            //[self.frontView viewWithTag:853].translatesAutoresizingMaskIntoConstraints = TRUE;
            //UIImageView *eyeImgView = (UIImageView*)[self.frontView viewWithTag:853];
            //CGRect eyeFrame = eyeImgView.frame;
            tagFrame.origin.y = ([UIScreen mainScreen].bounds.size.height) - appdeleg.window.safeAreaInsets.bottom - 60.0;//eyeFrame.origin.y;
            tagFrame.origin.x = appdeleg.window.safeAreaInsets.left + 16.0;
            //tagFrame.size.width = 30.0;
            //tagFrame.size.height = 30.0;
            [tagButton setFrame:tagFrame];
            //
            
            //[self.frontView layoutIfNeeded];
            //[self.view layoutIfNeeded];
            
            
            [self.frontView removeFromSuperview];
            [self.view addSubview:self.frontView];
            
        }else {
            UIStackView *stackview = (UIStackView*)[self.frontView viewWithTag:200];
            [stackview setAxis:UILayoutConstraintAxisHorizontal];
            [self.frontView viewWithTag:13].translatesAutoresizingMaskIntoConstraints = FALSE;
            
            [self.frontView viewWithTag:4].translatesAutoresizingMaskIntoConstraints = FALSE;
            
//            UIStackView *stackview = (UIStackView*)[self.frontView viewWithTag:200];
//            [stackview setAxis:UILayoutConstraintAxisHorizontal];
            
            
    //
//            CGRect frame1 = [UIScreen mainScreen].bounds;
//            frame1.origin.y = 0;
//            frame1.origin.x = [UIScreen mainScreen].bounds.size.height - 130;
//            frame1.size.height = [UIScreen mainScreen].bounds.size.width;
//            frame1.size.width = 95;

//            [[self.frontView viewWithTag:13] setFrame:frame1];
//            [self.frontView setNeedsLayout];
//            [self.frontView updateConstraintsIfNeeded];
        }
    }
}