このチュートリアルで示すように、スタティックセルテーブルビューで伸縮性のある自己調整イメージを作成するにはどうすればよいですか? http://blog.matthewcheok.com/design-teardown-stretchy-headers/スクロール時にスタティックセルテーブルビューで伸縮性のあるイメージを作成する方法
ダイナミックセルではなくスタティックセルの場合。
編集:
class ProfileViewController2: UITableViewController {
var profilePic = "WilsonLer"
private let kTableHeaderHeight: CGFloat = 189
var headerView: UIView!
@IBOutlet weak var topHeader: UITableViewCell!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let user = FIRAuth.auth()?.currentUser
self.navigationItem.title = user!.email
headerView = topHeader
tableView.contentInset = UIEdgeInsets(top: kTableHeaderHeight, left: 0, bottom: 0, right: 0)
tableView.contentOffset = CGPoint(x: 0, y: -kTableHeaderHeight)
updateHeaderView()
// to set and display profile image
let profilePicImage = topHeader.viewWithTag(1) as! UIImageView
let profilePicBG = topHeader.viewWithTag(2) as! UIImageView
profilePicImage.image = UIImage(named: profilePic)
profilePicBG.image = UIImage(named: profilePic)
profilePicImage.layer.cornerRadius = profilePicImage.frame.height/2
profilePicImage.clipsToBounds = true
profilePicImage.layer.borderWidth = 1
profilePicImage.layer.borderColor = UIColor.whiteColor().CGColor
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func updateHeaderView() {
var headerRect = CGRect(x: 0, y: -kTableHeaderHeight, width: tableView.bounds.width, height: kTableHeaderHeight)
if tableView.contentOffset.y < -kTableHeaderHeight {
headerRect.origin.y = tableView.contentOffset.y
headerRect.size.height = -tableView.contentOffset.y
}
topHeader.frame = headerRect
}
override func scrollViewDidScroll(scrollView: UIScrollView) {
updateHeaderView()
}
}
私は、リンクではなく、まだ無駄にする方法を試みました。セルのサブクラスを作成しようとしましたが、ダイナミックセルでのみ機能します。それは同じように動作します
おかげ
すでに試してみましたが役に立たない –
セルごとにカスタム*クラス*が必要なわけではありませんが、残りの部分はチェックアウトされます。 – NRitH