Note that there are some explanatory texts on larger screens.

plurals
  1. POBackground image too large in window/view
    primarykey
    data
    text
    <p>I am playing around with a very small single view application in order to understand how views work. I am extremely new to iOS development. I am using an image i put together as a background for my only view. When running the app my background is enormous. It's as if it is zoomed in or scaled. I am following a Big Nerd Ranch tutorial for views and as such I'm using a subclass of UIView called HypnosisView. This is temporary. It may also we worth noting that the image I am trying to use for a background is precisely 640 x 1136 pixels.</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. CGRect viewFrame = CGRectMake(0, 0, 640, 1136); HypnosisView *view = [[HypnosisView alloc] initWithFrame:viewFrame]; [view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"BG.png"]]]; [[self window] addSubview:view]; self.window.backgroundColor = [UIColor blackColor]; [self.window makeKeyAndVisible]; return YES; } </code></pre> <p>Updated code trying to implement a UIImageView using a 0, 0, 320, 568 frame. I also created a 320 sized background and then a full sized background and named them with the proper titles. </p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. CGRect viewFrame = CGRectMake(0, 0, 320, 568); UIImage *background = [UIImage imageNamed:@"background@2x.png"]; UIImageView *backgroundView = [[[UIImageView alloc] initWithImage:background] initWithFrame:viewFrame]; [[self window] addSubview:backgroundView]; [[self window] sendSubviewToBack:backgroundView]; self.window.backgroundColor = [UIColor clearColor]; [self.window makeKeyAndVisible]; return YES; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload