IOS development-copying Netease news and ios copying Netease news

Source: Internet
Author: User

IOS development-copying Netease news and ios copying Netease news

Learning Source: "top title scroll bar in quick integration App" by Mr. Yuan Yu

Effect:

Based on the Netease news interface, Requirement Analysis: required objects: 1. The navigation bar generated by the navigation controller by default. You can set the title above (you can also customize the View to set the navigation bar title) 2. Switch the title rolling area of the page to a ScrollView. add six UIButton, the UIButton text in sequence is the title of "headlines, hotspots, videos, society, subscription, and technology". 3. The Content Rolling area for switching content is a ScrollView, on this ScrollView, add six views about headlines, hotspots, videos, society, subscription, and technology in sequence with the title buttons in the title scroll area. 4. About headlines, hotspots, six Views of video, society, subscription, and technology, from six custom viewcontrollers. Logic to be processed: 5. Drag and Drop the content scroll area, but the two adjacent pages have a new page effect. A View automatically occupies the current page. 6. Select a title button in the title scroll area. The selected button is automatically switched to the center position, but the title buttons at both ends are not centered due to the scrolling area. 7. Select a title button in the title scroll area. The content scroll area switches to the corresponding View to display the corresponding View content. 8. Click a title button in the title scroll area, the status will be changed. The selected title is originally a font of Medium black size and switched to a large red font. The unselected title is originally a large red font and switched to a medium black font. In addition, the font size and color change must be dynamically changed, and will be gradually changed or changed as the content is dragged to the scroll area, rather than the end of the change. 9. Drag and Drop the content scroll area. After a page is rolled, the title scroll area automatically switches the corresponding title button and the title scroll area automatically switches to center. (Note that after one page is rolled, It is not changed while rolling) for more demand results, please continue to study in depth: requirements for additional association in "quick integration App top title scroll bar": the rolling range of the content scroll area and the rolling range of the title scroll area are determined by the number of title buttons, you must set a range of six times for the six buttons. Well, the analysis is so detailed. Next we will analyze the detailed requirements above to implement the functional module of webpage news step by step. First, I used xib to encapsulate this function, but when xib uses the navigation controller class, the title of the navigation controller class cannot be set, then I had to use the custom ViewController, then use the UIView custom imitation to set the navigation bar, then add UILabel in the navigation bar, and then add two scrollviews ON THE xib, at the same time, they have added an automatic layout. It is not difficult to automatically layout the layout here. If you understand it yourself, we will not detail it here: and then according to the above requirement 1 ~ 5

Based on requirements 6 and 7, the following:

Next I will repeat the remaining requirements:

8. Click a title button in the title scroll area to switch to the status. The selected title is originally a font of Medium black size and is switched to a large red font, the unselected title is originally a large red font and switched to a medium black font. In addition, the font size and color change must be dynamically changed, and will be gradually changed or changed as the content is dragged to the scroll area, rather than the end of the change. 9. Drag and Drop the content scroll area. After a page is rolled, the title scroll area automatically switches the corresponding title button and the title scroll area automatically switches to center. (Note that after one page is rolled, it does not change while scrolling)

According to requirement 8 and requirement 9, we need to respond to logical events based on the rolling area. Therefore, we need to use the UIScrollViewDelegate method here:

Complete requirement 9 first:

Then, complete requirement 8, and analyze it before completing:

 

Currently, adjacent buttons must be divided into left and right. The ratio of left button size to right should be equal to the ratio of left width to right width.

 

Here is a supplement:

In fact, all the requirements are met, but there is still a small detail that does not meet, that is, the page is started for the first time, the title is not set to the selected status by default, that is, the default color size is not set.

Now, all the requirements are basically fulfilled.

Because I have basically encapsulated this part of the module, it is worth repeating the download:

Baidu cloud download link: http://pan.baidu.com/s/1hrgurIW password: dtgv

Reprinted please indicate the source (http://www.cnblogs.com/goodboy-heyang/p/5134875.html), respect for labor results.

Added: modified the bug of subscript out-of-bounds.

 

Related Article

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.