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 7016209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:45:17+00:00 2026-05-27T22:45:17+00:00

I have a UIView which is my loading view. All it does is display

  • 0

I have a UIView which is my loading view. All it does is display the circular loading circle(lol to much “circle” for one sentence).
It works fine the first time but after that the circle is not centered. It moves to the left and down some. How can I get it to always be centered, take in mind I have limited the app to only display in the landscape modes (landscape left, landscape right) in all views so the issue is not coming from the device being rotated.

call to load the view:

loadingViewController = [LoadingViewController loadSpinnerIntoView:self.view];

LoadingViewController.h:

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "CrestronClient.h"
@interface LoadingViewController : UIView
{
    CrestronClient *cClient;


}
+(LoadingViewController *)loadSpinnerIntoView:(UIView *)superView;
-(void)removeLoadingView;
- (UIImage *)addBackground;
@end

LoadingView.m:

    #import "LoadingViewController.h"
#import "RootViewController.h"
@implementation LoadingViewController

CGRect priorFrameSettings;
UIView *parentView;


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations

    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation == UIInterfaceOrientationLandscapeRight ) {
        return YES;
    }else{
        return NO;
    }

}


-(void)removeLoadingView
{

//    [parentView setFrame:priorFrameSettings];

    CATransition *animation = [CATransition animation];

    [animation setType:kCATransitionFade];

    [[[self superview] layer] addAnimation:animation forKey:@"layerAnimation"];

    [self removeFromSuperview];
}

+(LoadingViewController *)loadSpinnerIntoView:(UIView *)superView
{

    priorFrameSettings = superView.frame;
    parentView = superView;
   // [superView setFrame:CGRectMake(0, 0, 1024, 1024)];


    // Create a new view with the same frame size as the superView


LoadingViewController *loadingViewController = [[LoadingViewController alloc] initWithFrame:superView.frame];

loadingViewController.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    // If something's gone wrong, abort!

    if(!loadingViewController){ return nil; }


    [superView addSubview:loadingViewController];

    if(!loadingViewController){ return nil; }

    // This is the new stuff here ;)

    UIActivityIndicatorView *indicator =

    [[[UIActivityIndicatorView alloc]

      initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge] autorelease];

    // Set the resizing mask so it's not stretched
    UIImageView *background = [[UIImageView alloc] initWithImage:[loadingViewController addBackground]];

    // Make a little bit of the superView show through

    background.alpha = 0.7;

    [loadingViewController addSubview:background];

    indicator.autoresizingMask =

    UIViewAutoresizingFlexibleTopMargin |

    UIViewAutoresizingFlexibleRightMargin |

    UIViewAutoresizingFlexibleBottomMargin |

    UIViewAutoresizingFlexibleLeftMargin;

    // Place it in the middle of the view

    indicator.center =   superView.center;

    // Add it into the spinnerView

    [loadingViewController addSubview:indicator];

    // Start it spinning! Don't miss this step

    [indicator startAnimating];


    // Create a new animation

    CATransition *animation = [CATransition animation];

    // Set the type to a nice wee fade

    [animation setType:kCATransitionFade];

    // Add it to the superView

    [[superView layer] addAnimation:animation forKey:@"layerAnimation"];


    return loadingViewController;

}
- (UIImage *)addBackground{

    cClient = [CrestronClient sharedManager];
    if (cClient.isConnected == FALSE) {
        [cClient connect];
    }
    // Create an image context (think of this as a canvas for our masterpiece) the same size as the view

    UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, 1);

    // Our gradient only has two locations - start and finish. More complex gradients might have more colours

    size_t num_locations = 2;

    // The location of the colors is at the start and end

    CGFloat locations[2] = { 0.0, 1.0 };

    // These are the colors! That's two RBGA values

    CGFloat components[8] = {

        0.4,0.4,0.4, 0.8,

        0.1,0.1,0.1, 0.5 };

    // Create a color space

    CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();

    // Create a gradient with the values we've set up

    CGGradientRef myGradient = CGGradientCreateWithColorComponents (myColorspace, components, locations, num_locations);

    // Set the radius to a nice size, 80% of the width. You can adjust this

    float myRadius = (self.bounds.size.width*.8)/2;

    // Now we draw the gradient into the context. Think painting onto the canvas

    CGContextDrawRadialGradient (UIGraphicsGetCurrentContext(), myGradient, self.center, 0, self.center, myRadius, kCGGradientDrawsAfterEndLocation);

    // Rip the 'canvas' into a UIImage object

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    // And release memory

    CGColorSpaceRelease(myColorspace);

    CGGradientRelease(myGradient);

    UIGraphicsEndImageContext();

    // … obvious.

    return image;

}
- (void)dealloc {

    [super dealloc];
}
@end
  • 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-05-27T22:45:18+00:00Added an answer on May 27, 2026 at 10:45 pm

    fixed the background by adding

    [background setFrame:CGRectMake(0, 0, 1024, 768 )];
    

    and fixed the centering of the circle with:

    indicator.center =   background.center;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIView on which i am loading my image view as a
I have a UIView in which I added a UITapGestureRecognizer . Inside that view
I have a UIView which i did transform using CGAffineTransformMakeScale Now my view is
I have a UIView element which I am adding to the main view controller.
Alright, I have a UIView which displays a CGPath which is rather wide. It
I have subclassed UIView object inside a uiscrollview which displays a pdf page. I
I have a UIControl (or UIView, doesn't matter which) and this is covered by
I have a small floating UIView, viewHover, which acts as a container to 2
I have a custom UIViewController, which is the only subView of UIView. The UIViewController
I have a custom UIView which is composed of many images, their positions are

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.