Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8550617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:59:25+00:00 2026-06-11T13:59:25+00:00

I’m trying to add an UIViewController that i created, but i want it to

  • 0

I’m trying to add an UIViewController that i created, but i want it to be a half of the screen size.

I’m using this code:

myController *tmController = [[myControlleralloc] initWithNibName:@"myController" bundle:nil];
    tmController .view.frame = CGRectMake(10, 100, 100, 100);
    [appDelegate.viewController presentModalViewController:tmController animated:YES];

but i see it on all the screen, what is wong with my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:59:27+00:00Added an answer on June 11, 2026 at 1:59 pm

    hi you can achieve this by category file…..

    .h file :

    #define kSemiModalAnimationDuration   0.5
    #define kSemiModalDidShowNotification @"kSemiModalDidShowNotification"
    #define kSemiModalDidHideNotification @"kSemiModalDidHideNotification"
    #define kSemiModalWasResizedNotification @"kSemiModalWasResizedNotification"
    @interface UIViewController (KNSemiModal)
    
    -(void)presentSemiViewController:(UIViewController*)vc;
    -(void)presentSemiView:(UIView*)vc;
    -(void)dismissSemiModalView;
    -(void)resizeSemiView:(CGSize)newSize;
    
    @end
    

    .m file:

        #import "UIViewController+KNSemiModal.h"
        #import <QuartzCore/QuartzCore.h>
    
        @interface UIViewController (KNSemiModalInternal)
        -(UIView*)parentTarget;
        -(CAAnimationGroup*)animationGroupForward:(BOOL)_forward;
        @end
    
        @implementation UIViewController (KNSemiModalInternal)
    
        -(UIView*)parentTarget {
          // To make it work with UINav & UITabbar as well
          UIViewController * target = self;
          while (target.parentViewController != nil) {
            target = target.parentViewController;
          }
          return target.view;
        }
    
        -(CAAnimationGroup*)animationGroupForward:(BOOL)_forward {
          // Create animation keys, forwards and backwards
          CATransform3D t1 = CATransform3DIdentity;
          t1.m34 = 1.0/-900;
          t1 = CATransform3DScale(t1, 0.95, 0.95, 1);
          t1 = CATransform3DRotate(t1, 15.0f*M_PI/180.0f, 1, 0, 0);
    
          CATransform3D t2 = CATransform3DIdentity;
          t2.m34 = t1.m34;
          t2 = CATransform3DTranslate(t2, 0, [self parentTarget].frame.size.height*-0.08, 0);
          t2 = CATransform3DScale(t2, 0.8, 0.8, 1);
    
          CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
          animation.toValue = [NSValue valueWithCATransform3D:t1];
          animation.duration = kSemiModalAnimationDuration/2;
          animation.fillMode = kCAFillModeForwards;
          animation.removedOnCompletion = NO;
          [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
    
          CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform"];
          animation2.toValue = [NSValue valueWithCATransform3D:(_forward?t2:CATransform3DIdentity)];
          animation2.beginTime = animation.duration;
          animation2.duration = animation.duration;
          animation2.fillMode = kCAFillModeForwards;
          animation2.removedOnCompletion = NO;
    
          CAAnimationGroup *group = [CAAnimationGroup animation];
          group.fillMode = kCAFillModeForwards;
          group.removedOnCompletion = NO;
          [group setDuration:animation.duration*2];
          [group setAnimations:[NSArray arrayWithObjects:animation,animation2, nil]];
          return group;
        }
        @end
    
        @implementation UIViewController (KNSemiModal)
    
        -(void)presentSemiViewController:(UIViewController*)vc {
          [self presentSemiView:vc.view];
        }
    
        -(void)presentSemiView:(UIView*)view {
          // Determine target
          UIView * target = [self parentTarget];
    
          if (![target.subviews containsObject:view]) {
            // Calulate all frames
            CGRect sf = view.frame;
            CGRect vf = target.frame;
            CGRect f  = CGRectMake(0, vf.size.height-sf.size.height, vf.size.width, sf.size.height);
            CGRect of = CGRectMake(0, 0, vf.size.width, vf.size.height-sf.size.height);
    
            // Add semi overlay
            UIView * overlay = [[UIView alloc] initWithFrame:target.bounds];
            overlay.backgroundColor = [UIColor blackColor];
    
            // Take screenshot and scale
            UIGraphicsBeginImageContextWithOptions(target.bounds.size, YES, [[UIScreen mainScreen] scale]);
            [target.layer renderInContext:UIGraphicsGetCurrentContext()];
            UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
            UIImageView * ss = [[UIImageView alloc] initWithImage:image];
            [overlay addSubview:ss];
            [target addSubview:overlay];
    
            // Dismiss button
            // Don't use UITapGestureRecognizer to avoid complex handling
            UIButton * dismissButton = [UIButton buttonWithType:UIButtonTypeCustom];
            [dismissButton addTarget:self action:@selector(dismissSemiModalView) forControlEvents:UIControlEventTouchUpInside];
            dismissButton.backgroundColor = [UIColor clearColor];
            dismissButton.frame = of;
            [overlay addSubview:dismissButton];
    
            // Begin overlay animation
            [ss.layer addAnimation:[self animationGroupForward:YES] forKey:@"pushedBackAnimation"];
            [UIView animateWithDuration:kSemiModalAnimationDuration animations:^{
              ss.alpha = 0.5;
            }];
    
            // Present view animated
            view.frame = CGRectMake(0, vf.size.height, vf.size.width, sf.size.height);
            [target addSubview:view];
            view.layer.shadowColor = [[UIColor blackColor] CGColor];
            view.layer.shadowOffset = CGSizeMake(0, -2);
            view.layer.shadowRadius = 5.0;
            view.layer.shadowOpacity = 0.8;
            view.layer.shouldRasterize = YES;
            view.layer.rasterizationScale = [[UIScreen mainScreen] scale];
            UIBezierPath *path = [UIBezierPath bezierPathWithRect:view.bounds];
            view.layer.shadowPath = path.CGPath;
    
            [UIView animateWithDuration:kSemiModalAnimationDuration animations:^{
              view.frame = f;
            } completion:^(BOOL finished) {
              if(finished){
                [[NSNotificationCenter defaultCenter] postNotificationName:kSemiModalDidShowNotification
                                                                    object:self];
              }
            }];
          }
        }
    
        -(void)dismissSemiModalView {
          UIView * target = [self parentTarget];
          UIView * modal = [target.subviews objectAtIndex:target.subviews.count-1];
          UIView * overlay = [target.subviews objectAtIndex:target.subviews.count-2];
          [UIView animateWithDuration:kSemiModalAnimationDuration animations:^{
            modal.frame = CGRectMake(0, target.frame.size.height, modal.frame.size.width, modal.frame.size.height);
          } completion:^(BOOL finished) {
            [overlay removeFromSuperview];
            [modal removeFromSuperview];
          }];
    
          // Begin overlay animation
          UIImageView * ss = (UIImageView*)[overlay.subviews objectAtIndex:0];
          [ss.layer addAnimation:[self animationGroupForward:NO] forKey:@"bringForwardAnimation"];
          [UIView animateWithDuration:kSemiModalAnimationDuration animations:^{
            ss.alpha = 1;
          } completion:^(BOOL finished) {
            if(finished){
              [[NSNotificationCenter defaultCenter] postNotificationName:kSemiModalDidHideNotification
                                                                  object:self];
            }
          }];
        }
    
        - (void)resizeSemiView:(CGSize)newSize {
          UIView * target = [self parentTarget];
          UIView * modal = [target.subviews objectAtIndex:target.subviews.count-1];
          CGRect mf = modal.frame;
          mf.size.width = newSize.width;
          mf.size.height = newSize.height;
          mf.origin.y = target.frame.size.height - mf.size.height;
          UIView * overlay = [target.subviews objectAtIndex:target.subviews.count-2];
          UIButton * button = [[overlay subviews] objectAtIndex:1];
          CGRect bf = button.frame;
          bf.size.height = overlay.frame.size.height - newSize.height;
          [UIView animateWithDuration:kSemiModalAnimationDuration animations:^{
            modal.frame = mf;
            button.frame = bf;
          } completion:^(BOOL finished) {
            if(finished){
              [[NSNotificationCenter defaultCenter] postNotificationName:kSemiModalWasResizedNotification
                                                                  object:self];
            }
          }];
        }
    
        @end
    
        #pragma mark - 
    
        // Convenient category method to find actual ViewController that contains a view
        // Adapted from: http://stackoverflow.com/questions/1340434/get-to-uiviewcontroller-from-uiview-on-iphone
    
        @implementation UIView (FindUIViewController)
        - (UIViewController *) containingViewController {
          UIView * target = self.superview ? self.superview : self;
          return (UIViewController *)[target traverseResponderChainForUIViewController];
        }
    
        - (id) traverseResponderChainForUIViewController {
          id nextResponder = [self nextResponder];
          BOOL isViewController = [nextResponder isKindOfClass:[UIViewController class]];
          BOOL isTabBarController = [nextResponder isKindOfClass:[UITabBarController class]];
          if (isViewController && !isTabBarController) {
            return nextResponder;
          } else if(isTabBarController){
            UITabBarController *tabBarController = nextResponder;
            return [tabBarController selectedViewController];
          } else if ([nextResponder isKindOfClass:[UIView class]]) {
            return [nextResponder traverseResponderChainForUIViewController];
          } else {
            return nil;
          }
        }
    
        @end
    
    #pragma mark - 
    
    // Convenient category method to find actual ViewController that contains a view
    // Adapted from: http://stackoverflow.com/questions/1340434/get-to-uiviewcontroller-from-uiview-on-iphone
    
    @implementation UIView (FindUIViewController)
    - (UIViewController *) containingViewController {
      UIView * target = self.superview ? self.superview : self;
      return (UIViewController *)[target traverseResponderChainForUIViewController];
    }
    
    - (id) traverseResponderChainForUIViewController {
      id nextResponder = [self nextResponder];
      BOOL isViewController = [nextResponder isKindOfClass:[UIViewController class]];
      BOOL isTabBarController = [nextResponder isKindOfClass:[UITabBarController class]];
      if (isViewController && !isTabBarController) {
        return nextResponder;
      } else if(isTabBarController){
        UITabBarController *tabBarController = nextResponder;
        return [tabBarController selectedViewController];
      } else if ([nextResponder isKindOfClass:[UIView class]]) {
        return [nextResponder traverseResponderChainForUIViewController];
      } else {
        return nil;
      }
    }
    
    @end
    

    and the call statement….

     KNFirstViewController *view=[[KNFirstViewController alloc]init];
        [self presentSemiView:view.view];
    

    see the example project Here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.