Plus add bookshelf, minus sign to reduce bookshelf (Code4app)

Source: Internet
Author: User
Tags add time set background

At the beginning:

Click to add Time:

Click to reduce the time:

ReaderViewController.h

#import <UIKit/UIKit.h>@interface  Readerviewcontroller:uiviewcontroller< Uiscrollviewdelegate>{    ** *scrollView;; -(void) add; -(void) dele; -(void) Reloadview; @end

Readerviewcontroller.m

#import "ReaderViewController.h"#defineImageHeight 120Static intnum =0;@interfaceReaderviewcontroller ()@end@implementationReaderviewcontroller- (ID) Initwithnibname: (NSString *) Nibnameornil Bundle: (NSBundle *) nibbundleornil{ Self=[Super Initwithnibname:nibnameornil Bundle:nibbundleornil]; if(self) {//Custom Initialization    }    returnSelf ;}- (void) viewdidload{[Super Viewdidload]; //Do any additional setup after loading the view. //the color of the fontSelf.navigationController.navigationBar.tintColor = [Uicolor colorwithred:248.0/255.0Green172.0/255.0Blue37.0/255.0Alpha1.0]; //navigation bar Background map[Self Addbackgroundview:@"1.png"]; //Left Delete buttonUibarbuttonitem *rightbarbutton =[[Uibarbuttonitem alloc] Initwithtitle:@"Delete"style:uibarbuttonitemstylebordered Target    : Self action: @selector (DELE)]; //Right Add buttonUibarbuttonitem *leftbarbutton =[[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemadd        Target:self Action: @selector (add)]; Self.navigationItem.rightBarButtonItem=Rightbarbutton; Self.navigationItem.leftBarButtonItem=Leftbarbutton; //ScrollerviewScrollView = [[Uiscrollview alloc] Initwithframe:cgrectmake (0,0, the,416)]; Scrollview.contentsize=cgsizemake ( the,480); //Set Background colorUIImage *backimg=[uiimage imagenamed:@"3.png"]; Uiimageview*backview=[[Uiimageview alloc] initwithimage:backimg]; Backview.frame=cgrectmake (0,0, the,480);        [Self.view Addsubview:backview];    [Self.view Addsubview:scrollview]; //re-refresh the interface[self Reloadview];}//title on navigation bar-(void) Addbackgroundview: (nsstring*) image{Uiimageview*imgview =[[Uiimageview alloc] initwithimage:[uiimage Imagenamed:image]]; Imgview.frame= CGRectMake (0,0, the, -);        [Self.navigationController.navigationBar Addsubview:imgview]; UILabel*title = [[UILabel alloc] Initwithframe:cgrectmake (( the- Max)/2,0, Max, -)]; [Title SetText:@"Bookshelf"];    [title Settextcolor:[uicolor Whitecolor];    [Title Settextalignment:nstextalignmentcenter];    [title Setshadowcolor:[uicolor Graycolor];    [title Setbackgroundcolor:[uicolor Clearcolor]; [Title Setfont:[uifont boldsystemfontofsize:20.0]]; [Self.navigationController.navigationBar addsubview:title];}//Adding a bookshelf-(void) add{Num++; UIImage*backimg=[uiimage imagenamed:@"2.png"]; Uiimageview*backview=[[Uiimageview alloc] initwithimage:backimg]; Backview.frame=cgrectmake (0, (num-1) *imageheight, the, ImageHeight); Backview.tag= num+ -;        [ScrollView Addsubview:backview]; if(num>3) {scrollview.contentsize=cgsizemake ( the, num*imageheight); }}//Remove a Bookshelf-(void) dele{if(num<=0) {        return; }         for(UIView *viewinchscrollview.subviews) {if(View.tag = = (num+ -) ) [View Removefromsuperview]; } num--; if(num>3) {scrollview.contentsize=cgsizemake ( the, num*imageheight); }    }//initialization of the main interface-(void) reloadview{NSLog (@"Reloadview"); //Traverse all the sub-interfaces of the current interface, remove the interface clean     for(UIView *viewinchscrollview.subviews)    {[View Removefromsuperview]; } scrollview.showsverticalscrollindicator=NO; Scrollview.showshorizontalscrollindicator=NO; ScrollView.Delegate=Self ;    [ScrollView Setscrollenabled:yes]; }

Plus add bookshelf, minus sign to reduce bookshelf (Code4app)

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.