SHARE
TWEET

Untitled

a guest Apr 26th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 let minimalConteinerHeight: CGFloat = ((UIScreen.main.bounds.height * 25) / 100) + 50
  2.                 let maximumConteinerHeight: CGFloat = ((UIScreen.main.bounds.height * 70) / 100) + 50
  3.                
  4.                 let ratio = image.size.width / image.size.height
  5.                 if headerView!.frame.width > headerView!.frame.height {
  6.                     let newHeight = headerView!.frame.width / ratio
  7.                     if image.size.height < minimalConteinerHeight {
  8.                         headerView?.coverImageView.contentMode = .center
  9.                         headerView!.frame.size = CGSize(width: headerView!.frame.width, height: minimalConteinerHeight)
  10.                     } else if image.size.height > maximumConteinerHeight || newHeight > maximumConteinerHeight {
  11.                         headerView?.coverImageView.contentMode = .scaleAspectFit
  12.                         headerView!.frame.size = CGSize(width: headerView!.frame.width, height: maximumConteinerHeight)
  13.                     } else {
  14.                         headerView?.coverImageView.contentMode = .scaleAspectFill
  15.                         headerView!.frame.size = CGSize(width: headerView!.frame.width, height: newHeight)
  16.                     }
  17.                    
  18.                 } else {
  19.                     let newWidth = headerView!.frame.height * ratio
  20.                     headerView!.frame.size = CGSize(width: newWidth, height: headerView!.frame.height)
  21.                 }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top