Skip to content

Commit

Permalink
调整
Browse files Browse the repository at this point in the history
  • Loading branch information
gsdios committed Mar 25, 2016
1 parent 8a1aa85 commit 89bea85
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion SDAutoLayoutDemo/DemoVC/DemoVC0/DemoVC0.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ - (void)animation

}

- (void)dealloc
- (void)viewDidDisappear:(BOOL)animated
{
[_timer invalidate];
_timer = nil;
Expand Down
4 changes: 2 additions & 2 deletions SDAutoLayoutDemo/DemoVC/DemoVC7/DemoVC7.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

////// 此步设置用于实现cell的frame缓存,可以让tableview滑动更加流畅 //////

cell.sd_tableView = tableView;
cell.sd_indexPath = indexPath;
// cell.sd_tableView = tableView;
// cell.sd_indexPath = indexPath;

///////////////////////////////////////////////////////////////////////

Expand Down
41 changes: 39 additions & 2 deletions SDAutoLayoutDemo/SDAutoLayout/UIView+SDAutoLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ - (void)sd_layoutSubviews
[self.autoLayoutModelsArray enumerateObjectsUsingBlock:^(SDAutoLayoutModel *model, NSUInteger idx, BOOL *stop) {
if (caches) {
model.needsAutoResizeView.frame = [[caches objectAtIndex:idx] CGRectValue];
[self setupCornerRadiusWithView:model.needsAutoResizeView model:model];
} else {
[self sd_resizeWithModel:model];
}
Expand Down Expand Up @@ -912,7 +913,7 @@ - (void)sd_layoutSubviews
}
}

if (self.sd_rightViewsArray.count && (self.ownLayoutModel.right || self.ownLayoutModel.equalRight)) {
if (![self isKindOfClass:[UIScrollView class]] && self.sd_rightViewsArray.count && (self.ownLayoutModel.right || self.ownLayoutModel.equalRight)) {
SDAutoLayoutModel *model = self.ownLayoutModel;
UIView *view = self;
if (model.right) {
Expand Down Expand Up @@ -944,6 +945,37 @@ - (void)sd_layoutSubviews
}
}

if (![self isKindOfClass:[UIScrollView class]] && self.sd_bottomViewsArray.count && (self.ownLayoutModel.bottom || self.ownLayoutModel.equalBottom)) {
SDAutoLayoutModel *model = self.ownLayoutModel;
UIView *view = self;
if (model.bottom) {
if (view.superview == model.bottom.refView) {
if (!view.fixedHeight) {
view.height = view.superview.height - view.top - [model.bottom.value floatValue];
}
view.bottom = model.bottom.refView.height - [model.bottom.value floatValue];
} else {
if (!view.fixedHeight) {
view.height = model.bottom.refView.top - view.top - [model.bottom.value floatValue];
}
view.bottom = model.bottom.refView.top - [model.bottom.value floatValue];
}

} else if (model.equalBottom) {
if (view.superview == model.equalBottom.refView) {
if (!view.fixedHeight) {
view.height = view.superview.height - view.top;
}
view.bottom = model.equalBottom.refView.height;
} else {
if (!view.fixedHeight) {
view.height = model.equalBottom.refView.bottom - view.top;
}
view.bottom = model.equalBottom.refView.bottom;
}
}
}

if (self.didFinishAutoLayoutBlock) {
self.didFinishAutoLayoutBlock(self.frame);
}
Expand Down Expand Up @@ -1222,6 +1254,12 @@ - (void)sd_resizeWithModel:(SDAutoLayoutModel *)model
}


[self setupCornerRadiusWithView:view model:model];

}

- (void)setupCornerRadiusWithView:(UIView *)view model:(SDAutoLayoutModel *)model
{
CGFloat cornerRadius = view.layer.cornerRadius;
CGFloat newCornerRadius = 0;

Expand All @@ -1237,7 +1275,6 @@ - (void)sd_resizeWithModel:(SDAutoLayoutModel *)model
view.layer.cornerRadius = newCornerRadius;
view.clipsToBounds = YES;
}

}

- (void)addAutoLayoutModel:(SDAutoLayoutModel *)model
Expand Down

0 comments on commit 89bea85

Please sign in to comment.