2016-04-26 19 views
0

私はセルの行の高さを変更することができましたが、アイコンとして使用するイメージは同じサイズのままで、現在は小さすぎます。私はそれがセルの左側に72x72に張り付いていることを望みます。セル内の画像の表示サイズを変更するにはどうすればよいですか?

私はcellForRowAtIndexPathに次のように使用しています:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

    let cell = cellForTableView(tableView) 
    let checklist = dataModel.lists[indexPath.row] 
    cell.textLabel?.textColor = UIColor(red: 25.0/255.0, green: 25.0/255.0, blue: 112.0/255.0, alpha: 1.0) 
    cell.textLabel?.font = font 
    cell.textLabel!.text = checklist.name 
    cell.textLabel?.adjustsFontSizeToFitWidth = true 
    cell.textLabel?.textAlignment = NSTextAlignment.Left 
    cell.accessoryType = .DetailDisclosureButton 
    cell.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.5) 

    cell.imageView!.image = UIImage(named: checklist.iconName) 

    return cell 
} 

func cellForTableView(tableView: UITableView) -> UITableViewCell { 
    let cellIdentifier = "Cell" 
    if let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier) { 
     return cell 
    } else { 
     return UITableViewCell(style: .Subtitle, reuseIdentifier: cellIdentifier) 
    } 
} 

私はそのような場合にはサイズを設定するにはどうすればよいですか?

+0

セルとimageViewの作成方法とオートレイアウトまたはフレーミングを使用していますか? –

+0

ええ - ちょうど私の質問を編集;)。 – Laroms

+0

細胞クラスはどうですか?細胞はどのように作られていますか? –

答えて

1

ストーリーボードを使用していますか?その場合は、自動レイアウトを使用して、imageViewの幅と高さを適用することができます。 autolayoutを使って左側に貼り付けることもできます。

と呼ばれる自動レイアウト制約をプログラムで適用できる素晴らしいココアポッドもあります。

+0

いいえ、すべてそのテーブルビューに対してプログラムによって実行されます。 Snapkit?私はそれを見ている。 – Laroms

+0

yeapは、あなたの人生をはるかに簡単にします。 – Polis

関連する問題