Skip to content

Commit

Permalink
代码布局的调整
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsic committed May 15, 2017
1 parent 9d2feba commit 271ba9a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions SGAdvertScrollView/SGAdvertScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,19 @@ - (void)layoutSubviews {
[super layoutSubviews];

// 设置图片尺寸
CGFloat imageViewX = SGMargin;
CGFloat imageViewY = 0.5 * SGMargin;
CGFloat imageViewH = self.frame.size.height - 2 * imageViewY;
CGFloat imageViewW = imageViewH;
_imageView.frame = CGRectMake(imageViewX, imageViewY, imageViewW, imageViewH);
if (self.advertScrollViewStyle == SGAdvertScrollViewStyleTwo) { // 左边提示图片根据图片尺寸距离顶部、底部间距为 5
CGFloat imageViewX = SGMargin;
CGFloat imageViewY = 0.5 * SGMargin;
CGFloat imageViewH = self.frame.size.height - 2 * imageViewY;
CGFloat imageViewW = imageViewH;
_imageView.frame = CGRectMake(imageViewX, imageViewY, imageViewW, imageViewH);
} else { // 左边提示图片根据图片尺寸自适应
CGFloat imageViewW = _imageView.image.size.width;
CGFloat imageViewH = _imageView.image.size.height;
CGFloat imageViewX = SGMargin;
CGFloat imageViewY = 0.5 * (self.frame.size.height - imageViewH);
_imageView.frame = CGRectMake(imageViewX, imageViewY, imageViewW, imageViewH);
}

// 设置分割线尺寸
CGFloat separatorX = CGRectGetMaxX(_imageView.frame) + 0.5 * SGMargin;
Expand Down

0 comments on commit 271ba9a

Please sign in to comment.