Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define TAG_FOTO_HEADER 1
- -(void)parallaxForHeaderScrollView:(UIScrollView *)scrollView
- {
- UIView *v = self.tableView.tableHeaderView;
- UIImageView *i = (UIImageView *) [v viewWithTag:TAG_FOTO_HEADER];
- CGFloat y = -scrollView.contentOffset.y;
- if (y<0) return;
- CGRect fV = v.frame;
- fV.size.height = 150 + y;
- fV.origin.y = -y;
- [v setFrame:fV];
- [v setClipsToBounds:YES];
- //Parallax
- CGRect f = CGRectMake(0.0f, -170.0f, 320.0f, 320.0f);
- f.origin.y += y / 0.75f;
- [i setFrame:f];
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
- [self parallaxForHeaderScrollView:scrollView];
- }
- - (UIView *)configureTop
- {
- UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 150.0f)] autorelease];
- UIImageView *t = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, -170.0f, 320.0f, 320.0f)];
- t.image = [UIImage imageNamed:@"the_name_of_the_background_image.jpg"]; //Put your image here
- [view addSubview:t];
- [t setTag:TAG_FOTO_HEADER];
- [iZ3Tools setShadowToView:t WithOffset:CGSizeMake(0.0f, -2.0f) WithColor:[UIColor blackColor] WithRadius:0.2f WithOpacity:0.75f];
- [view setBackgroundColor:[UIColor grayColor]];
- //Put more elements on your header here
- return view;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- // Set up the edit and add buttons.
- [self.tableView setTableHeaderView:[self configureTop]];
- [self.tableView setBounces:YES];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement