├── LeftView ├── View │ ├── NMLeftTableView.h │ ├── NMImageView.h │ ├── NMleftTableViewCell.h │ ├── NMleftTableViewCell.m │ ├── NMLeftTableView.m │ └── NMImageView.m ├── NMLeftViewController.h ├── Controller │ ├── NMLeftTableViewController.h │ └── NMLeftTableViewController.m └── NMLeftViewController.m └── README.md /LeftView/View/NMLeftTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NMLeftTableView.h 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/7. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NMLeftTableView : UITableView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /LeftView/NMLeftViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NMLeftViewController.h 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/3. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NMLeftViewController : UITableViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /LeftView/Controller/NMLeftTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NMLeftTableViewController.h 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/5. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NMLeftTableViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /LeftView/View/NMImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NMImageView.h 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/4. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NMImageView : UIView 12 | 13 | @property (nonatomic,copy)NSString *backgroundImageName; 14 | @property (nonatomic,copy)NSString *btnName; 15 | @property (nonatomic,copy)NSString *faceViewName; 16 | 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /LeftView/View/NMleftTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // NMleftTableViewCell.h 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/7. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum{ 12 | NMleftTableViewCellNone = 0, 13 | NMleftTableViewCellString, 14 | NMleftTableViewCellImage, 15 | NMleftTableViewCellSwitch 16 | }NMleftTableViewCellType; 17 | 18 | 19 | @interface NMleftTableViewCell : UITableViewCell 20 | 21 | +(instancetype)cellWithTableView:(UITableView *)tableView; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /LeftView/View/NMleftTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // NMleftTableViewCell.m 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/7. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import "NMleftTableViewCell.h" 10 | #import "UIView+Extension.h" 11 | @implementation NMleftTableViewCell 12 | 13 | +(instancetype)cellWithTableView:(UITableView *)tableView 14 | { 15 | static NSString *ID = @"leftTableCell"; 16 | NMleftTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; 17 | if (cell == nil) { 18 | cell = [[NMleftTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID]; 19 | } 20 | 21 | return cell; 22 | } 23 | 24 | 25 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 26 | 27 | if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 28 | //设置左标题 29 | // UISwitch *aSwitch = [[UISwitch alloc] init]; 30 | // self.accessoryView = aSwitch; 31 | self.detailTextLabel.font = [UIFont systemFontOfSize:11]; 32 | // self.detailTextLabel.textAlignment = NSTextAlignmentNatural; 33 | 34 | } 35 | return self; 36 | } 37 | 38 | -(void)layoutSubviews{ 39 | [super layoutSubviews]; 40 | self.detailTextLabel.x = self.detailTextLabel.x - ([UIScreen mainScreen].bounds.size.width - LeftViewWidth); 41 | // self.detailTextLabel.y = self.detailTextLabel.y + 3; 42 | 43 | 44 | 45 | self.accessoryView.x = self.accessoryView.x -([UIScreen mainScreen].bounds.size.width - LeftViewWidth); 46 | //self.detailTextLabel.te 47 | 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 仿网易云音乐-NetMusic 2 | 3 | ##前言 4 | 5 | 仿网易云音乐界面及部分功能实现 6 | 7 | 项目的介绍地址:http://xiaobaiso.me/blog/net-music.html 8 | 9 | 喜欢优秀的软件,简单而简约 10 | 11 | 12 | ##最终实现的功能 13 | - 播放本地音乐提供同一歌单内歌曲的上下一首,单曲循环,列表循环,随机播放等功能 14 | - 播放网络音乐提供从网络上搜索关键字,呈现结果后由用户选择歌曲下载并且播放。 15 | - 播放的基本功能为快进快退,任意位置播放 16 | 17 | ##最终实现的界面 18 | 19 | - 由于只是实现一部分在线听歌功能(网易云音乐的中央界面使用WEB界面搭建,所以其更换界面就可以完成界面的多种多样,而这一块实现需要多人协助,故不实现了),故需要考考留下来功能的前后关联性,应该完成完整的使用流程。 20 | - 完成网易云音乐的标志性的几个界面及特效 21 | - 旋转封面 22 | - 提示界面 23 | - 虚化背景 24 | - 界面左右分离 25 | - 歌曲分主界面端以及小状态栏 26 | 27 | 28 | ##项目计划思维图 29 | . 30 | 31 | . 32 | 33 | 34 | 35 | 36 | ##界面显示效果 37 | 38 | 39 | . 40 | 41 | 42 | . 43 | 44 | 45 | . 46 | 47 | 48 | . 49 | 50 | 51 | . 52 | 53 | 54 | . 55 | 56 | 57 | . 58 | 59 | 60 | . 61 | 62 | -------------------------------------------------------------------------------- /LeftView/View/NMLeftTableView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NMLeftTableView.m 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/7. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import "NMLeftTableView.h" 10 | #import "NMleftTableViewCell.h" 11 | 12 | @interface NMLeftTableView () 13 | @property (nonatomic,strong)NSArray *tableViewBtnInfo; 14 | 15 | @end 16 | 17 | 18 | @implementation NMLeftTableView 19 | 20 | -(NSArray *)tableViewBtnInfo 21 | { 22 | if (_tableViewBtnInfo == nil) { 23 | NSString *path = [[NSBundle mainBundle] pathForResource:@"leftViewBtn" ofType:@"plist"]; 24 | _tableViewBtnInfo = [NSArray arrayWithContentsOfFile:path]; 25 | } 26 | 27 | return _tableViewBtnInfo; 28 | } 29 | 30 | 31 | 32 | -(instancetype)initWithFrame:(CGRect)frame 33 | { 34 | NSLog(@"12345"); 35 | if (self = [super initWithFrame:frame]) { 36 | // self.backgroundColor = [UIColor greenColor]; 37 | self.delegate = self; 38 | self.dataSource = self;//这个不能少 39 | 40 | } 41 | 42 | return self; 43 | 44 | } 45 | 46 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 47 | return 2; 48 | } 49 | 50 | 51 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 52 | NSLog(@"bab"); 53 | #warning Incomplete method implementation. 54 | // Return the number of rows in the section. 55 | return 3; 56 | } 57 | 58 | 59 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 60 | { 61 | NSLog(@"ttt"); 62 | static NSString *CellIdentifier = @"MYCell"; 63 | NMleftTableViewCell *cell = [NMleftTableViewCell cellWithTableView:tableView]; 64 | UISwitch *aSwitch = [[UISwitch alloc] init]; 65 | cell.accessoryView = aSwitch; 66 | 67 | NSDictionary *btninfo = self.tableViewBtnInfo[0]; 68 | cell.imageView.image = [UIImage imageNamed:@"cm2_msg_icn_msg"]; 69 | cell.textLabel.text = @"dddd"; 70 | cell.detailTextLabel.text = @"hero.intro"; 71 | return cell; 72 | } 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /LeftView/NMLeftViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NMLeftViewController.m 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/3. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import "NMLeftViewController.h" 10 | #import "UIView+Extension.h" 11 | 12 | #import "NMImageView.h" 13 | #import "NMLeftTableViewController.h" 14 | #import "NMLeftTableView.h" 15 | @interface NMLeftViewController () 16 | 17 | @end 18 | 19 | @implementation NMLeftViewController 20 | 21 | -(void)setupImageView{ 22 | // UIImageView *imageView = [[UIImageView alloc]init]; 23 | // 24 | // 25 | // 26 | // NSString *path = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"1706442046308354.jpg"]; 27 | // 28 | // imageView.image = [UIImage imageWithContentsOfFile:path]; 29 | // 30 | // 31 | // XBlog(@"image = %@",imageView.image); 32 | // 33 | // imageView.frame = CGRectMake(0, 0, LeftViewWidth, ImageViewHeigth); 34 | // [self.view addSubview:imageView]; 35 | 36 | NMImageView *imageView = [[NMImageView alloc] initWithFrame:CGRectMake(0, 0, LeftViewWidth, ImageViewHeigth)]; 37 | // imageView.frame = CGRectMake(0, 0, LeftViewWidth, ImageViewHeigth); 38 | imageView.backgroundColor = [UIColor whiteColor]; 39 | [self.view addSubview:imageView]; 40 | 41 | } 42 | 43 | 44 | -(void)setupTableView{ 45 | NSLog(@"self.view %f",self.view.width); 46 | // NMLeftTableViewController *controller = [[NMLeftTableViewController alloc] init]; 47 | // controller.tableView.frame = CGRectMake(0, ImageViewHeigth, self.view.width, 800);//外面设置了大小 48 | // 49 | 50 | 51 | NMLeftTableView *tableView = [[NMLeftTableView alloc] init]; 52 | tableView.frame = CGRectMake(0, ImageViewHeigth, self.view.width, 800);//外面设置了大小 53 | //controller.view.x = 0; 54 | 55 | 56 | 57 | 58 | 59 | 60 | [self.view addSubview:tableView]; 61 | } 62 | 63 | 64 | - (void)viewDidLoad { 65 | [super viewDidLoad]; 66 | NSLog(@"%@",NSHomeDirectory()); 67 | 68 | self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;//去掉全部的cell质检的横线 69 | // self.tableView.bounces = NO;//多余不能超出来,就是上下两个不能滑出来 70 | 71 | [self setupImageView]; 72 | [self setupTableView]; 73 | 74 | 75 | } 76 | 77 | 78 | //- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 79 | //{ 80 | // return 200; 81 | // if (section == 0) 82 | // return CGFLOAT_MIN; 83 | // return tableView.sectionHeaderHeight; 84 | //} 85 | 86 | 87 | 88 | 89 | 90 | 91 | - (void)didReceiveMemoryWarning { 92 | [super didReceiveMemoryWarning]; 93 | // Dispose of any resources that can be recreated. 94 | } 95 | 96 | 97 | 98 | 99 | /* 100 | #pragma mark - Navigation 101 | 102 | // In a storyboard-based application, you will often want to do a little preparation before navigation 103 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 104 | // Get the new view controller using [segue destinationViewController]. 105 | // Pass the selected object to the new view controller. 106 | } 107 | */ 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /LeftView/Controller/NMLeftTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NMLeftTableViewController.m 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/5. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import "NMLeftTableViewController.h" 10 | 11 | @interface NMLeftTableViewController () 12 | 13 | @end 14 | 15 | @implementation NMLeftTableViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | // self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;//去掉全部的cell质检的横线 21 | // self.tableView.bounces = NO;//多余不能超出来,就是上下两个不能滑出来 22 | 23 | //self.view.backgroundColor = [UIColor redColor]; 24 | 25 | 26 | 27 | self.tableView.backgroundColor = [UIColor redColor]; 28 | self.tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain]; 29 | 30 | self.tableView.delegate = self; 31 | self.tableView.dataSource=self; 32 | [self.tableView reloadData]; 33 | } 34 | 35 | - (void)didReceiveMemoryWarning { 36 | [super didReceiveMemoryWarning]; 37 | // Dispose of any resources that can be recreated. 38 | } 39 | 40 | #pragma mark - Table view data source 41 | 42 | //- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 43 | //#warning Potentially incomplete method implementation. 44 | // // Return the number of sections. 45 | // return 1; 46 | //} 47 | 48 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 49 | NSLog(@"bab"); 50 | #warning Incomplete method implementation. 51 | // Return the number of rows in the section. 52 | return 3; 53 | } 54 | 55 | 56 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 57 | { 58 | NSLog(@"ttt"); 59 | static NSString *CellIdentifier = @"MYCell"; 60 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 61 | 62 | if (cell==nil) { 63 | cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 64 | } 65 | cell.imageView.image = [UIImage imageNamed:@"cm2_msg_icn_msg"]; 66 | cell.textLabel.text = @"dddd"; 67 | return cell; 68 | } 69 | 70 | 71 | 72 | 73 | 74 | /* 75 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 76 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; 77 | 78 | // Configure the cell... 79 | 80 | return cell; 81 | } 82 | */ 83 | 84 | /* 85 | // Override to support conditional editing of the table view. 86 | - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 87 | // Return NO if you do not want the specified item to be editable. 88 | return YES; 89 | } 90 | */ 91 | 92 | /* 93 | // Override to support editing the table view. 94 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 95 | if (editingStyle == UITableViewCellEditingStyleDelete) { 96 | // Delete the row from the data source 97 | [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 98 | } else if (editingStyle == UITableViewCellEditingStyleInsert) { 99 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 100 | } 101 | } 102 | */ 103 | 104 | /* 105 | // Override to support rearranging the table view. 106 | - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 107 | } 108 | */ 109 | 110 | /* 111 | // Override to support conditional rearranging of the table view. 112 | - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 113 | // Return NO if you do not want the item to be re-orderable. 114 | return YES; 115 | } 116 | */ 117 | 118 | /* 119 | #pragma mark - Navigation 120 | 121 | // In a storyboard-based application, you will often want to do a little preparation before navigation 122 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 123 | // Get the new view controller using [segue destinationViewController]. 124 | // Pass the selected object to the new view controller. 125 | } 126 | */ 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /LeftView/View/NMImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NMImageView.m 3 | // XBNetMusic 4 | // 5 | // Created by 小白 on 15/12/4. 6 | // Copyright (c) 2015年 小白. All rights reserved. 7 | // 8 | 9 | #import "NMImageView.h" 10 | #import "UIView+Extension.h" 11 | @interface NMImageView () 12 | @property (nonatomic,strong)UIImageView *backgroundView; 13 | @property (nonatomic,strong)UIButton *btn; 14 | @property (nonatomic,strong)UIImageView *faceView;//这里不讲username和faceView打包到一个view的原因是因为username会撑大这个整体的view 导致有大量空白,影响用户点击 15 | @property (nonatomic,strong)UIButton *username; 16 | @end 17 | 18 | 19 | @implementation NMImageView 20 | 21 | 22 | -(void)setupBackgroundView 23 | { 24 | UIImageView *imageView = [[UIImageView alloc]init]; 25 | imageView.frame = CGRectMake(0, 0, self.width, self.height); 26 | //这里图片放到了打包里面去了,要按照这个方法去找文件,加载。一般来说,取打包文件的图片是不占用缓存的,使用images.xcassets是要占用的 27 | NSString *path = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"1706442046308354.jpg"]; 28 | imageView.image = [UIImage imageWithContentsOfFile:path]; 29 | self.backgroundView = imageView; 30 | [self addSubview:imageView]; 31 | } 32 | 33 | 34 | -(void)setupFaceView{ 35 | UIImageView *imageView = [[UIImageView alloc] init]; 36 | CGFloat w = 50; 37 | CGFloat h = 50; 38 | CGFloat x = 10; 39 | CGFloat y = self.username.y - h ; 40 | XBlog(@"CGRectGetMaxY(self.username.frame) = %f",CGRectGetMaxY(self.username.frame)); 41 | imageView.frame = CGRectMake(x, y, w, h); 42 | //设置圆形 43 | imageView.layer.cornerRadius = 25; 44 | imageView.layer.masksToBounds = YES; 45 | 46 | NSString *path = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"cm2_icn_user_who.png"]; 47 | imageView.image= [UIImage imageWithContentsOfFile:path]; 48 | 49 | 50 | imageView.userInteractionEnabled=YES; 51 | UITapGestureRecognizer *singleTap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(userInfoClick)]; 52 | [imageView addGestureRecognizer:singleTap]; 53 | 54 | 55 | 56 | [self addSubview:imageView]; 57 | self.faceView = imageView; 58 | } 59 | 60 | 61 | /* 62 | 设置用户名 63 | */ 64 | -(void)setupUsername{ 65 | UIButton *username = [UIButton buttonWithType:UIButtonTypeCustom]; 66 | [username setTitle:@"小白" forState:UIControlStateNormal]; 67 | [username setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 68 | username.titleLabel.font = [UIFont boldSystemFontOfSize:17];//这里加粗字体 69 | [username sizeToFit];//这里根据名字自动设置大小 70 | 71 | username.x = 15; 72 | username.y = self.height - 5 - username.height; 73 | 74 | [username addTarget:self action:@selector(userInfoClick) forControlEvents:UIControlEventTouchUpInside]; 75 | 76 | self.username = username; 77 | [self addSubview:username]; 78 | 79 | } 80 | 81 | -(void)userInfoClick{ 82 | XBlog(@"用户信息被点击"); 83 | } 84 | 85 | 86 | /* 87 | 设置签到按钮 88 | */ 89 | -(void)setupBtn{ 90 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 91 | CGFloat w = 55; 92 | CGFloat h = 22; 93 | CGFloat x = self.width - w - 10; 94 | CGFloat y = ImageViewHeigth - h - 15; 95 | 96 | btn.frame = CGRectMake(x,y,w,h); 97 | [btn setTitle:@" 签到" forState:UIControlStateNormal];//设置按钮必须要用这个啊 用.那个好像不好用啊 98 | [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 99 | btn.titleLabel.font = [UIFont systemFontOfSize:12]; 100 | 101 | 102 | // UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cm2_lay_icn_jifen"]]; 103 | [btn setImage:[UIImage imageNamed:@"cm2_lay_icn_jifen"] forState:UIControlStateNormal]; 104 | [btn setImage:nil forState:UIControlStateDisabled]; 105 | 106 | 107 | 108 | //设置边框颜色 109 | btn.layer.borderColor = [[UIColor whiteColor] CGColor]; 110 | //设置边框宽度 111 | btn.layer.borderWidth = 1.0f; 112 | //设置圆角 113 | btn.layer.cornerRadius = 5.0f; 114 | //设置子空间不可超出父控件 115 | btn.layer.masksToBounds = YES; 116 | 117 | 118 | 119 | [btn addTarget:self action:@selector(checkinBtnClick) forControlEvents:UIControlEventTouchUpInside]; 120 | 121 | 122 | //btn.backgroundColor = [UIColor redColor]; 123 | [self addSubview:btn]; 124 | self.btn = btn; 125 | } 126 | 127 | -(void)checkinBtnClick{ 128 | XBlog(@"签到按下了"); 129 | [self.btn setTitle:@"已签到" forState:UIControlStateNormal]; 130 | [self.btn setImage:nil forState:UIControlStateNormal]; 131 | self.btn.enabled = NO; 132 | } 133 | 134 | 135 | 136 | 137 | 138 | -(instancetype)initWithFrame:(CGRect)frame{ 139 | if (self = [super initWithFrame:frame]) { 140 | [self setupBackgroundView]; 141 | [self setupBtn]; 142 | 143 | [self setupUsername]; 144 | [self setupFaceView]; 145 | self.layer.masksToBounds = YES;//这个属性设置后,子视图只能在父视图里面了 不可超出 146 | } 147 | return self; 148 | } 149 | 150 | 151 | @end 152 | --------------------------------------------------------------------------------