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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:44:11+00:00 2026-05-26T21:44:11+00:00

The problem: On top of existing UIView, load a background image From the card

  • 0

The problem:

  1. On top of existing UIView, load a background image
  2. From the card deck image (big image), cut 1 card (a part of a big image) and
  3. Place that card on top of the background image

The following code works. It does exactly what i need it do to. I ask you though ..

  1. Am i doing it right? Is this the way it’s done?
  2. Are all steps i used really needed? I have a strong suspicion i made it more complicated then it needs to be

Thank you for your time

// Define overall UIView area and create a view
UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];

// Gain access to background image
UIImage *backgroundImage = [UIImage imageNamed:@"green_background.jpg"]; 

// Put background image on top of a 
UIImageView *myImageView = [[UIImageView alloc] initWithImage:backgroundImage];

// So now we have the view of some size with some image bahind it
[background addSubview:myImageView];    


// #####################################################################

CGRect positionOnParentView = CGRectMake(40, 40, 50, 130);

CGImageRef bigImage = [UIImage imageNamed:@"cards.png"].CGImage;    
CGImageRef partOfABigImage = CGImageCreateWithImageInRect(bigImage, CGRectMake(0, 0, 200, 50));

// get an image to be displayed
UIImage *partOfImage = [UIImage imageWithCGImage:partOfABigImage];

// Put it on it's onw view
UIImageView *cardImage = [[UIImageView alloc] initWithImage:partOfImage];

// create a UIview and add image 
UIView *card = [[UIView alloc] initWithFrame:positionOnParentView];
[card addSubview:cardImage];

[background addSubview:card];

[[self view] addSubview:background];
  • 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-26T21:44:12+00:00Added an answer on May 26, 2026 at 9:44 pm

    You’re creating this view hierarchy:

    UIView (self.view)
      UIView (background)
        UIImageView (backgroundImage - backgroundImage)
        UIView (card)
          UIImageView (cardImage - partOfABigImage)
    

    A UIImageView can have subviews. So do you need all of those intermediate views? Would this simpler hierarchy be sufficient?

    UIImageView (self.view - backgroundImage)
      UIImageView (cardImage - partOfABigImage)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem aligning an image to the top the text in an
EDIT: The main problem seemed to be that I was just doing Add Existing
I have an existing win from with two group boxes groupbox1 at top while
Background: I'm developing an application that involves taking an existing pdf form and overlaying
Please go to: http://jlecologia.com/page1c.html to see the problem The top box look fine but
i have a problem with IE8 + jQuery.css('top') function. 1) I have a DIV
Top of the morning to ye people on various surfaces of earth. The problem:
This problem is only in IE. Consider the following HTML: <html> <body> <div style='position:absolute;left:1em;right:1em;top:1em;bottom:1em;overflow:auto;>
I'm trying to display a UILabel on top of a UINavigationController. The problem is
I'm working on a drop down menu with margin-top. The problem is, 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.