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)