|
| 1 | +// |
| 2 | +// QYMySelfVC.m |
| 3 | +// Weibo |
| 4 | +// |
| 5 | +// Created by qingyun on 16/5/14. |
| 6 | +// Copyright © 2016年 QingYun. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import "QYMySelfVC.h" |
| 10 | + |
| 11 | +@interface QYMySelfVC () |
| 12 | +@property (weak, nonatomic) IBOutlet UIView *headerView; |
| 13 | + |
| 14 | +@property (strong, nonatomic) UIImageView *imageView; |
| 15 | + |
| 16 | +@property (nonatomic) CGRect bgFrame; |
| 17 | + |
| 18 | +@end |
| 19 | + |
| 20 | +@implementation QYMySelfVC |
| 21 | + |
| 22 | +-(UIImageView *)imageView{ |
| 23 | + if (_imageView == nil) { |
| 24 | + _imageView = [[UIImageView alloc] initWithFrame:_headerView.bounds]; |
| 25 | + _imageView.contentMode = UIViewContentModeScaleAspectFill; |
| 26 | + _imageView.image = [UIImage imageNamed:@"headerView"]; |
| 27 | + _imageView.clipsToBounds = YES; |
| 28 | + } |
| 29 | + return _imageView; |
| 30 | +} |
| 31 | + |
| 32 | +- (void)viewDidLoad { |
| 33 | + [super viewDidLoad]; |
| 34 | + |
| 35 | +} |
| 36 | + |
| 37 | +//视图已经显示的时候调用 |
| 38 | +-(void)viewDidAppear:(BOOL)animated{ |
| 39 | + [super viewDidAppear:animated]; |
| 40 | + [_headerView addSubview:self.imageView]; |
| 41 | + _bgFrame = self.imageView.frame; |
| 42 | +} |
| 43 | + |
| 44 | +#pragma mark -UIScrollViewDelegate |
| 45 | +-(void)scrollViewDidScroll:(UIScrollView *)scrollView{ |
| 46 | + CGPoint offset = self.tableView.contentOffset; |
| 47 | + |
| 48 | + NSInteger offsetY = -offset.y; |
| 49 | + |
| 50 | + if (offsetY > 0) { |
| 51 | + CGRect frame = self.bgFrame; |
| 52 | + frame.size.height += offsetY; |
| 53 | + frame.origin.y -= offsetY; |
| 54 | + self.imageView.frame = frame; |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +#pragma mark - Table view data source |
| 59 | + |
| 60 | +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { |
| 61 | +#warning Incomplete implementation, return the number of sections |
| 62 | + return 0; |
| 63 | +} |
| 64 | + |
| 65 | +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
| 66 | +#warning Incomplete implementation, return the number of rows |
| 67 | + return 0; |
| 68 | +} |
| 69 | + |
| 70 | +/* |
| 71 | +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
| 72 | + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; |
| 73 | + |
| 74 | + // Configure the cell... |
| 75 | + |
| 76 | + return cell; |
| 77 | +} |
| 78 | +*/ |
| 79 | + |
| 80 | +/* |
| 81 | +// Override to support conditional editing of the table view. |
| 82 | +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { |
| 83 | + // Return NO if you do not want the specified item to be editable. |
| 84 | + return YES; |
| 85 | +} |
| 86 | +*/ |
| 87 | + |
| 88 | +/* |
| 89 | +// Override to support editing the table view. |
| 90 | +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { |
| 91 | + if (editingStyle == UITableViewCellEditingStyleDelete) { |
| 92 | + // Delete the row from the data source |
| 93 | + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; |
| 94 | + } else if (editingStyle == UITableViewCellEditingStyleInsert) { |
| 95 | + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view |
| 96 | + } |
| 97 | +} |
| 98 | +*/ |
| 99 | + |
| 100 | +/* |
| 101 | +// Override to support rearranging the table view. |
| 102 | +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { |
| 103 | +} |
| 104 | +*/ |
| 105 | + |
| 106 | +/* |
| 107 | +// Override to support conditional rearranging of the table view. |
| 108 | +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { |
| 109 | + // Return NO if you do not want the item to be re-orderable. |
| 110 | + return YES; |
| 111 | +} |
| 112 | +*/ |
| 113 | + |
| 114 | +/* |
| 115 | +#pragma mark - Navigation |
| 116 | +
|
| 117 | +// In a storyboard-based application, you will often want to do a little preparation before navigation |
| 118 | +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { |
| 119 | + // Get the new view controller using [segue destinationViewController]. |
| 120 | + // Pass the selected object to the new view controller. |
| 121 | +} |
| 122 | +*/ |
| 123 | + |
| 124 | +@end |
0 commit comments