Scroll down, and the title will also scroll down (like the Global Times ).

Source: Internet
Author: User

Scroll down, and the title will also scroll down (like the Global Times ).

 

Select the first one:

Select the second one:

Project directory:

Note that this Code introduces the third-party library SVSegmentedControl

RootViewController. h

#import <UIKit/UIKit.h>#import "SVSegmentedControl.h"@interface RootViewController : UIViewController<UIScrollViewDelegate>{    UIScrollView *scrollView1;    UIScrollView *scrollView2;    UIPageControl *pag;    NSMutableArray *dataArray;    SVSegmentedControl *options;}@end

 

RootViewController. m

# Pragma-mark-functions-(void) initBackGroundView {// hide the navigation bar self. navigationController. navigationBarHidden = YES; // scrollView1 = [[UIScrollView alloc] init]; scrollView1.frame = CGRectMake (0, 40,320,400); details = [UIColor grayColor]; scrollView1.delegate = self; scrollView1.pagingEnabled = YES; scrollView1.contentSize = CGSizeMake (320*2,376); [self. view addSubview: scrollView1]; // UIView * v1 = [[UIView alloc] init]; [v1 setFrame: CGRectMake (0, 0,320,376)]; v1.backgroundColor = [UIColor redColor]; [scrollView1 addSubview: v1]; // UIView * v2 = [[UIView alloc] init]; v2.frame = CGRectMake (320, 0,320,376); v2.backgroundColor = [UIColor blueColor]; [scrollView1 addSubview: v2]; // The dot pag = [[UIPageControl alloc] initWithFrame: CGRectMake (160,400, 0, 0, 0)]; pag. numberOfPages = 2; pag. currentPage = 0; [self. view addSubview: pag]; // The sliding icon options = [[SVSegmentedControl alloc] initWithSectionTitles: [NSArray arrayWithObjects: @ "car purchase application", @ "car owner application ", nil]; [options addTarget: self action: @ selector (actiBtClick :) forControlEvents: UIControlEventValueChanged]; [options setBackgroundImage: [UIImage imageNamed: @ "switchBg.png"]; options. center = CGPointMake (160, 50); options. crossFadeLabelsOnDrag = YES; options. selectedIndex = 0; options. textColor = [UIColor blackColor]; options. LKWidth = 120; options. textShadowOffset = CGSizeMake (0, 0); options. textShadowColor = [UIColor clearColor]; options. height = 30; options. thumb. backgroundImage = [UIImage imageNamed: @ "-2.png"]; options. thumb. highlightedBackgroundImage = [UIImage imageNamed: @" -2.png"]; options. thumb. textShadowColor = [UIColor clearColor]; options. thumb. textShadowOffset = CGSizeMake (0, 0); [self. view addSubview: options] ;}# pragma-mark-doClickActions-(void) actiBtClick :( SVSegmentedControl *) sender {if (sender. selectedIndex = 0) {[scrollView1 setContentOffset: CGPointMake (0, scrollView1.contentOffset. y) animated: YES]; pag. currentPage = 0;} else if (sender. selectedIndex = 1) {[scrollView1 setContentOffset: CGPointMake (320, scrollView1.contentOffset. y) animated: YES]; pag. currentPage = 1 ;}# pragma-mark-scrollViewDelegate-(void) scrollViewDidEndDecelerating :( UIScrollView *) scrollView {if (scrollView1.contentOffset. x = 0) {pag. currentPage = 0; [options moveThumbToIndex: 0 animate: YES];} else if (scrollView1.contentOffset. x = 320) {pag. currentPage = 1; [options moveThumbToIndex: 1 animate: YES] ;}}

 


Why does the navigation or title bar move when the QQ space is scroll up or down with the mouse?

To customize the navigation and title bar of a space, add the code for the space (code is available on the Internet) and you can go to Baidu on the Internet. Hope to help you, welcome to adopt.
 
How can I hover an image over a webpage? the scroll bar will also scroll, similar to the QQ floating box, code

If you are a website, please do it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.