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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:58:16+00:00 2026-06-03T07:58:16+00:00

I have a UIViewController Class which holds 2 custom UIView classes which are: ItemView

  • 0

I have a UIViewController Class which holds 2 custom UIView classes which are:

ItemView

DrawingView

in UIViewController ViewDidLoad method I have the following code:

- (void)viewDidLoad
{

    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    item = [[ItemView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/2, 230, 230)];
    item.opaque = NO;

    [self.view addSubview:item];

    drawing = [[DrawingView alloc] initWithFrame:self.view.frame];
    [self.view insertSubview:drawing aboveSubview:item];
    [item release];
    [drawing release];

}

The DrawingView class gets UITouches and accordingly draw on the screen.

My question is:

I can draw all over the screen except for on top of ItemView class object. DrawingView class cannot draw on to ItemView.

Let me explain it in another word:

The DrawView class works on the screen except for the area of itemView subview. On top of itemView, DrawView cannot make any draws but other than itemView area, it makes drawing.

What can I do?
What can be the problem?
How can I make drawing on all screen including the itemView area added by addSubview on ViewController class?

EDIT: I am adding a screenshot in order to explain the problem better

in this image link you can see that, I can draw on the white area but I cannot draw on the face which is an image loaded by ItemView class.

EDIT 2: I found that the problem is related to opacity. In the ItemView class, I changed the added UIImageView object alpha value to 0.5f.
The result is semi-transparent view and now my finger drawing is visible. However, this is not what I want. I want to draw on top of the view. I do not want to play with the alpha value.

  • 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-03T07:58:18+00:00Added an answer on June 3, 2026 at 7:58 am

    Finally, I found the answer myself. It is not exactly what I wanted but my solution is based on CALayer.

    Instead of using a custom UIView class like ItemView I added the following class method in ItemView Class:

    +(CALayer *)imgLayer
    {
        UIImage *img = [UIImage imageNamed:@"face.png"];
        CALayer *layer = [CALayer layer];
        CGFloat nativeWidth = CGImageGetWidth(img.CGImage);
        CGFloat nativeHeight = CGImageGetHeight(img.CGImage);
        CGRect startFrame = CGRectMake(0, 0, nativeWidth, nativeHeight);
        layer.contents = (id)img.CGImage;
        layer.frame = startFrame;
        return layer;
    
    }
    

    In My UIVIewController Class I called my static function as following:

        CAGradientLayer *bgLayer =  [GradientView greyGradient];
        bgLayer.frame = self.view.bounds;
        [self.view.layer insertSublayer:bgLayer atIndex:0];
    
        CALayer *imgLayer =[ItemView imgLayer];
        imgLayer.frame = self.view.bounds;
        [self.view.layer insertSublayer:imgLayer above:bgLayer];
    

    And it works! now I can make drawings on my image.

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

Sidebar

Related Questions

I have the following code to my UIViewController class implementation: - (void)viewDidLoad { CustomUITableView
In my iPhone app, I have a custom UIViewController class setup which adds some
I have a UIView class which I add to my main UIViewController and I
i have a UIViewController class that do the following: detect movement. array a bunch
I have a UIViewController class and a second which I want to push modally
Here is the situation: I have a class MainView (which is a UIViewController) and
So I have a UIViewController A which adds a UIView B as a subclass.
I have a UIViewController class, which has a button which triggers this: DetailViewController *viewController
I have MyViewController class which is subclass of UIViewController. I want to draw filled
I have a class that subclasses UIView called DrawView. This class contains custom drawing

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.