IOS代码笔记之仿电子书书架效果

2020-01-15 16:07:22于丽

RootTableViewCell.h


#import <UIKit/UIKit.h>

@interface RootTableViewCell : UITableViewCell
@property(nonatomic,strong) UIButton * bookLeft;
@property(nonatomic,strong) UIButton * bookMiddle;
@property(nonatomic,strong) UIButton * bookRight;
@end 

RootTableViewCell.m


#import "RootTableViewCell.h"

@implementation RootTableViewCell
@synthesize bookLeft;
@synthesize bookMiddle;
@synthesize bookRight;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
 if (self) {
 // Initialization code
 
 UIImageView * imageview= [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 416/3)];
 imageview.image = [UIImage imageNamed:@"BookShelfCell.png"];
 [self addSubview:imageview];
 
 bookLeft = [UIButton buttonWithType:UIButtonTypeCustom];
 bookLeft.frame = CGRectMake(10, 10, 280/3, 376/3-20);
 bookLeft.tag = 1;
 
 bookMiddle = [UIButton buttonWithType:UIButtonTypeCustom];
 bookMiddle.frame = CGRectMake(20+280/3, 10, 280/3, 376/3-20);
 bookMiddle.tag = 2;
 
 bookRight = [UIButton buttonWithType:UIButtonTypeCustom];
 bookRight.frame = CGRectMake(30+280/3*2, 10, 280/3, 376/3-20);
 bookRight.tag = 3;
 
 [self addSubview:bookLeft];
 [self addSubview:bookMiddle];
 [self addSubview:bookRight];
 }
 return self;
}

大家还可以结合《iOS模仿电子书首页实现书架布局样式》这篇文章进行学习。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持ASPKU。

 

注:相关教程知识阅读请移步到IOS开发频道。