The plus sign adds the bookshelves, minus the number minus the bookshelves (code4App), and the bookshelves code4app
At the beginning:
When you click Add:
Click to decrease:
ReaderViewController. h
#import <UIKit/UIKit.h>@interface ReaderViewController : UIViewController<UIScrollViewDelegate>{ UIScrollView *scrollView;}@property(nonatomic,strong) UIScrollView *scrollView;;-(void)add;-(void)dele;-(void)reloadView;@end
ReaderViewController. m
# Import "ReaderViewController. h "# define ImageHeight 120 static int num = 0; @ interface ReaderViewController () @ end @ implementation ReaderViewController-(id) initWithNibName :( NSString *) nibNameOrNil bundle :( NSBundle *) else {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization} return self;}-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. // font color self. navigationController. navigationBar. tintColor = [UIColor colorWithRed: 248.0/255.0 green: 172.0/255.0 blue: 37.0/255.0 alpha: 1.0]; // navigation bar background image [self addBackgroundView: @ "1.png"]; // The delete button on the left UIBarButtonItem * rightBarButton = [[UIBarButtonItem alloc] initWithTitle: @ "delete" style: UIBarButtonItemStyleBordered target: self action: @ selector (dele)]; // add UIBarButtonItem * leftBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemAdd target: self action: @ selector (add)]; self. navigationItem. rightBarButtonItem = rightBarButton; self. navigationItem. leftBarButtonItem = leftBarButton; // scrollerView scrollView = [[UIScrollView alloc] initWithFrame: CGRectMake (0, 0,320,416)]; scrollView. contentSize = CGSizeMake (320,480); // set the background color UIImage * backimg = [UIImage imageNamed: @ "3.png"]; UIImageView * backview = [[UIImageView alloc] initWithImage: backimg]; backview. frame = CGRectMake (0, 0,320,480); [self. view addSubview: backview]; [self. view addSubview: scrollView]; // refresh the interface [self reloadView];} // Title on the navigation bar-(void) addBackgroundView :( NSString *) image {UIImageView * imgView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: image]; imgView. frame = CGRectMake (0, 0,320, 44); [self. navigationController. navigationBar addSubview: imgView]; UILabel * title = [[UILabel alloc] initWithFrame: CGRectMake (320-150)/2, 0,150, 44)]; [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];} // add a bookshelf-(void) add {num ++; UIImage * backimg = [UIImage imageNamed: @ "2.png"]; UIImageView * backview = [[UIImageView alloc] initWithImage: backimg]; backview. frame = CGRectMake (0, (num-1) * ImageHeight, 320, ImageHeight); backview. tag = num + 100; [scrollView addSubview: backview]; if (num> 3) {scrollView. contentSize = CGSizeMake (320, num * ImageHeight) ;}// delete a bookshelf-(void) dele {if (num <= 0) {return ;} for (UIView * view in scrollView. subviews) {if (view. tag = (num + 100) [view removeFromSuperview];} num --; if (num> 3) {scrollView. contentSize = CGSizeMake (320, num * ImageHeight) ;}// initialize the main interface-(void) reloadView {NSLog (@ "reloadView "); // traverse all the subinterfaces of the current interface and delete the subinterfaces clean for (UIView * view in scrollView. subviews) {[view removeFromSuperview];} scrollView. showsVerticalScrollIndicator = NO; scrollView. showsHorizontalScrollIndicator = NO; scrollView. delegate = self; [scrollView setScrollEnabled: YES];}
How to download code4app
Click the Download button on each page to download each piece of code.
How to watch code4app videos on iphone
Use the UC browser or Baidu video to watch videos online. Download an all-around player locally.