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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:16:32+00:00 2026-05-29T07:16:32+00:00

I create UITabBar template. Then I add to firstViewController a tableView. Make connections (UITableViewDataSource

  • 0

I create UITabBar template. Then I add to firstViewController a tableView. Make connections (UITableViewDataSource and UITableViewDelegate).
In didselect method I need to render selected UITableViewCell and animate it to one of UITabBars.
If I render UITableViewCell row = 0 – it’s ok, But if I render UITableViewCell row > 0 (1,2,…) I get black rectangle.
I can render UITableViewCell contentView, but it will render without background.
How can I get snapshot of UITableViewCell with a background?

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UITabBarController *tabBarController;

@end

#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"

@implementation AppDelegate

@synthesize window = _window;
@synthesize tabBarController = _tabBarController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
}


#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController <UITableViewDelegate,     UITableViewDataSource>

@property (nonatomic, strong) IBOutlet UITableView *tableViewAnimation;
@property (nonatomic, retain) UIImageView *thumbnail;

- (UIImage*)screenshotFromView:(UIView *)view;

@end


#import "FirstViewController.h"
#import <QuartzCore/QuartzCore.h>

@implementation FirstViewController
@synthesize tableViewAnimation = _tableViewAnimation;
@synthesize thumbnail = _thumbnail;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"First", @"First");
        self.tabBarItem.image = [UIImage imageNamed:@"first"];
    }
    return self;
}


#pragma mark - UITableView DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section     {
    NSUInteger count = 10;
    return count;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    
    static NSString *goodsListCellIdentifier = @"ListOfGoodsIndetifier";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:goodsListCellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:goodsListCellIdentifier];
        cell.textLabel.backgroundColor = [UIColor clearColor];
    }

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = @"detalied view";

return cell;
}

#pragma mark - UITableView Delegate
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor redColor];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [_tableViewAnimation cellForRowAtIndexPath:indexPath];
    CGRect imageViewFrame = cell.frame;
    imageViewFrame.origin.y = 64.0 + tableView.frame.origin.y + imageViewFrame.origin.y     - tableView.contentOffset.y;
//    imageViewFrame.size.width = cell.contentView.frame.size.width;
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:imageViewFrame];

    imageView.image = [self screenshotFromView:cell];
    [self.tabBarController.view addSubview:imageView];
    self.thumbnail = imageView;
    self.thumbnail.hidden = NO;
    self.view.userInteractionEnabled = NO;
    [UIView animateWithDuration:1.0 
                     animations:^{
                         CGRect tabBarFrame =  self.tabBarController.tabBar.frame;
                         CGFloat xoffset = tabBarFrame.size.width / 2;
                         [_thumbnail setCenter:CGPointMake(xoffset * 0.5, tabBarFrame.origin.y + 25.0)];
                         [_thumbnail setTransform:CGAffineTransformMakeScale(0.1, 0.1)];
                         [_thumbnail setAlpha:0.4];
                     }
                     completion:^(BOOL finished){
                         [self.thumbnail removeFromSuperview];
                         self.thumbnail = nil;
                         self.view.userInteractionEnabled = YES;
                     }];
}

- (UIImage*)screenshotFromView:(UIView *)view {
    // Create a graphics context with the target size
    // On iOS 4 and later, use UIGraphicsBeginImageContextWithOptions to take the scale into consideration
    // On iOS prior to 4, fall back to use UIGraphicsBeginImageContext
    CGSize imageSize = view.bounds.size;
    UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);

    CGContextRef context = UIGraphicsGetCurrentContext();

    // -renderInContext: renders in the coordinate space of the layer,
    // so we must first apply the layer's geometry to the graphics context
    CGContextSaveGState(context);
    // Center the context around the window's anchor point
    CGContextTranslateCTM(context, [view center].x, [view center].y);
    // Apply the window's transform about the anchor point
    CGContextConcatCTM(context, [view transform]);
    // Offset by the portion of the bounds left of and above the anchor point
    CGContextTranslateCTM(context, -[view bounds].size.width * [[view layer] anchorPoint].x, -[view bounds].size.height * [[view layer] anchorPoint].y);

    // Render the layer hierarchy to the current context
    [[view layer] renderInContext:context];

    // Restore the context
    CGContextRestoreGState(context);

    // Retrieve the screenshot image
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

   return image;
}

@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-29T07:16:33+00:00Added an answer on May 29, 2026 at 7:16 am

    Just comment next lines:

    // Center the context around the window's anchor point
    //    CGContextTranslateCTM(context, [view center].x, [view center].y);
    // Apply the window's transform about the anchor point
    //    CGContextConcatCTM(context, [view transform]);
    // Offset by the portion of the bounds left of and above the anchor point
    //    CGContextTranslateCTM(context, -[view bounds].size.width * [[view layer] anchorPoint].x, -[view bounds].size.height * [[view layer] anchorPoint].y);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use a UITabBar in my project. I did not create a
I don't use UITabbarController,I just add the UITabbar in ViewController.I know when we use
Need a GUI with many tabs (TabBarController and UITabBar) and one fullscreen view, e.g.
How do you create a raised item within a UITabBar? For example, Instagram has
Create one listview and add the item in listview like listview1.Items.Add(new ListViewItem(hello i am
I create an iPhone app base on uitableview and uitabbar. On each cell of
I'm trying to add a UIButton to UITabBar in my iPad application with following
I have 2 UIViewControllers in a UITabBar and would like to create a facade
create table foo (id, name varchar(255), value varchar(255)); Does it make sense to index
Is there any way how I can create a UITabBar with options such as

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.