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

  • Home
  • SEARCH
  • 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 211979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:08:38+00:00 2026-05-11T18:08:38+00:00

NOTE: I added my new solution at the UPDATE answer below. I try to

  • 0

NOTE: I added my new solution at the UPDATE answer below.

I try to recreate the effects we saw in Mobile Safari’s tab on iPhone/iPod touch.

Basically, it’s a UIScrollView that holds 4 reusable UIView (acting like ring buffer), and scrolls horizontally. When scrolling, the UIView’s opacity will fade in/out seamlessly with offset.

Currently, I do all the dirty job in - (void)scrollViewDidScroll:(UIScrollView *)scrollView. Such as getting the contentOffset from UIScrollView, determine the pageingation, calculate the delta between contentOffset and each UIView positions, and decide/set the alpha value of each UIView at the moment when scrollViewDidScroll: was called.

And it works, performance is okay, everything runs smoothly, but the only problem is too much calculating.

I tried UIView’s beginAnimations: and commitAnimations:, but it’s useless in scrollViewDidScroll:, since 1) the new alpha value still have to be calculate by myself, and 2) scrollViewDidScroll: kept called when scrolling, it’s meaningless to do the animation here. Is there any way to rewrite this part with Core Animation? So I don’t have to do the math myself on alpha value of each UIView, instead, I can left whole works to Core Animation.

  • 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-11T18:08:38+00:00Added an answer on May 11, 2026 at 6:08 pm

    UPDATE

    I came up with another way to update alpha value of each page. When creating content view, I use KVO to addObserver with UIScrollView’s contentOffset:

    [self.scrollView addObserver:[self.contentViews objectAtIndex:i] 
                      forKeyPath:@"contentOffset" 
                         options:NSKeyValueObservingOptionNew
                         context:@selector(updateAlpha:)];
    

    So that each of my contentViews will get the message when contentOffset changed:

    - (void)observeValueForKeyPath:(NSString *)keyPath 
                          ofObject:(id)object 
                            change:(NSDictionary *)change 
                           context:(void *)context {
        [self performSelector:(SEL)context withObject:change];
    }
    

    And my contentViews can do the calculation and animate by themselves when scrolling:

    - (void)updateAlpha:(NSDictionary *)change {
        CGFloat offset = [[change objectForKey:NSKeyValueChangeNewKey] CGPointValue].x;
        CGFloat origin = [self frame].origin.x;
        CGFloat delta = fabs(origin - offset);
    
        [UIView beginAnimations:@"Fading" context:nil];
        if (delta < [self frame].size.width) {
            self.alpha = 1 - delta/self.frame.size.width*0.7;
        } else {
            self.alpha = 0.3;
        }
        [UIView commitAnimations];
    }
    

    Of course, you will need to remove the observer when you remove the content view from superview, and add them again when new content view created.

    Hope this help to those who want to do the same.

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

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Figured this one out on my own moments ago. Turns… May 11, 2026 at 11:51 pm
  • Editorial Team
    Editorial Team added an answer You don't necessarily have to delete "old" data all the… May 11, 2026 at 11:51 pm
  • Editorial Team
    Editorial Team added an answer Although it looks like it, for(int i = 0; i… May 11, 2026 at 11:51 pm

Related Questions

I want to add a constant value onto an incoming bound integer. In fact
I have been extremely naughty. I have been developing a piece of software (I'm
I'm working on a project which is just about to start, and since I
i've written a UserControl descendant that is in an assembly dll. How do i

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.