<!–
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Menlo; color: #ba0011; background-color: #c1ffbb}
–>
<!–
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Menlo; color: #2e0d6e; background-color: #c1ffbb}
span.s1 {font: 17.0px Menlo; color: #000000}
span.s2 {color: #b40062}
span.s3 {color: #448993}
span.s4 {color: #ba0011}
–>
[self.tableView addObserver:self forKeyPath:@”contentOffset” options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:nil];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
CGPoint oldPoint = [change[@"old"] CGPointValue];
CGPoint newPoint = [change[@"new"] CGPointValue];
// NSLog(@"%@",change);
CGFloat newY = newPoint.y;
CGFloat oldY = oldPoint.y;
if ( newY - oldY > 0) { //判断 self.imageView.y -= newY; self.tableView.y = self.imageView.bottom; [self.tableView setContentOffset:CGPointMake(, )]; }
else if ( newY - oldY < ) {
// self.imageView.y = self.imageView.y - newY;
// if (self.imageView.y >= 0) {
// self.imageView.y = 0;
// }
// self.tableView.y = self.imageView.bottom;
self.imageView.y -= newY; self.tableView.y = self.imageView.bottom; [self.tableView setContentOffset:CGPointMake(, )]; }}
https://github.com/yongliangP/YLSpringHeader
https://github.com/Cloudox/ScrollShowHeaderDemo
https://www.jianshu.com/p/8e4ed860d460
section 圆角 阴影
https://www.cnblogs.com/yeng/p/10540167.html
//===============Cell==================@interface SubCell : UITableViewCell@property (nonatomic, strong) SubCellShadowView *bgView;@property (nonatomic, strong) NSIndexPath *indexPath;@property (nonatomic) NSInteger rowInSection;//每一组的行数@end@implementation SubCell- (void)awakeFromNib { [super awakeFromNib]; self.selectionStyle = UITableViewCellSelectionStyleNone; self.clipsToBounds = NO; SubCellShadowView *bgView = [[SubCellShadowView alloc] init]; [self insertSubview:bgView atIndex:]; self.bgView= bgView; CAShapeLayer *shadow = [CAShapeLayer layer]; shadow.shadowColor = [UIColor blackColor].CGColor; shadow.shadowOffset=CGSizeMake(,); shadow.shadowOpacity=0.15; [bgView.layeraddSublayer:shadow]; bgView.shadowLayer= shadow; CALayer*line = [CALayerlayer]; line.backgroundColor = [UIColor groupTableViewBackgroundColor].CGColor; [bgView.layeraddSublayer:line]; bgView.separatorLine= line;}-(void)layoutSubviews{ [super layoutSubviews]; UIBezierPath*bgBezierPath =nil; CGFloat cornerRaduis =7.0;//觉得阴影大的可以把半径调小,半径大的话阴影面积会变大 if(self.indexPath.row== && self.rowInSection==) {//单组单行 self.bgView.clipsToBounds=NO; self.bgView.frame=self.bounds; CGRect rect = UIEdgeInsetsInsetRect(self.bgView.bounds, UIEdgeInsetsMake(, , , )); bgBezierPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(cornerRaduis, cornerRaduis)]; }elseif(self.indexPath.row==) {// 第一行 self.bgView.clipsToBounds=YES; self.bgView.frame = UIEdgeInsetsInsetRect(self.bounds, UIEdgeInsetsMake(-, , , )); CGRect rect = UIEdgeInsetsInsetRect(self.bgView.bounds, UIEdgeInsetsMake(, , , )); bgBezierPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(cornerRaduis, cornerRaduis)]; }elseif(self.indexPath.row==self.rowInSection-) {// 最后一行 self.bgView.clipsToBounds=YES; self.bgView.frame = UIEdgeInsetsInsetRect(self.bounds, UIEdgeInsetsMake(, , -, )); CGRect rect = UIEdgeInsetsInsetRect(self.bgView.bounds, UIEdgeInsetsMake(, , , )); bgBezierPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:(UIRectCornerBottomLeft|UIRectCornerBottomRight) cornerRadii:CGSizeMake(cornerRaduis, cornerRaduis)]; }else{// 中间行 self.bgView.clipsToBounds=YES; self.bgView.frame = UIEdgeInsetsInsetRect(self.bounds, UIEdgeInsetsMake(, , , )); CGRect rect = UIEdgeInsetsInsetRect(self.bgView.bounds, UIEdgeInsetsMake(, , , )); bgBezierPath = [UIBezierPathbezierPathWithRect:rect]; } self.bgView.shadowLayer.path= bgBezierPath.CGPath; self.bgView.shadowLayer.shadowPath= bgBezierPath.CGPath; self.bgView.shadowLayer.fillColor = [UIColor whiteColor].CGColor; //分割线 非单组单行 非最后一行 if(!(self.indexPath.row==&&self.rowInSection==) && !(self.indexPath.row==self.rowInSection-)) { self.bgView.separatorLine.frame = CGRectMake(self.bgView.frame.origin.x+, self.bgView.frame.size.height-, self.bgView.frame.size.width-*, 1.0); }}@end