iOS Programmatic Custom TableViewCells with Stevia
First initialize your podfile in the terminal by going to the Project Directory and type
iOS Programmatic Custom TableViewCells with Stevia

First initialize your podfile in the terminal by going to the Project Directory and type
pod init
Open the podfile and write the following
open Podfile
//inside podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Project' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'SteviaLayout', '4.5.0'
# Pods for Project
end
Now create a customTableView cell class and import stevia
import Stevia
class TransactionCell: UITableViewCell {
Add all your needed components
let totalCostLabel = UILabel()
let categoryList = ["Shopping", "Food & Drick", "Travel", "Groceries", "Gas", "Bills & Utilities", "Miscellaneous"]
Write init functions and layout the UI Objects
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
private func commonInit() {
configureLayout()
}
private func configureLayout() {
sv(totalCostLabel)
totalCostLabel.right(21).centerVertically()
}
Now in your viewController adopt the TableView Data Source and TableView Delegate Protocols and import Stevia
import Stevia
class TransactionViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{
Create the TableView object
let tableView = UITableView()
Register the dataSource, delegate, and custom cell in ViewDidLoad
tableView.dataSource = self
tableView.delegate = self
tableView.register(TransactionCell.self, forCellReuseIdentifier: "transactionCell")
Place the TableView into the view
view.sv(
tableView
)
tableView.left(0).right(0).top(0).bottom(0)
Implement the tableview protocols functions
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return categoryList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "transactionCell", for: indexPath) as! TransactionCell
cell.textLabel?.text = categoryList[indexPath.row]
cell.totalCostLabel.text = "$0"
return cell
} 메타데이터
- post_id
- e6a962dedffc
- slug
- ios-programmatic-custom-tableviewcells-with-stevia-e6a962dedffc
- url
- https://medium.com/@ahrchen/ios-programmatic-custom-tableviewcells-with-stevia-e6a962dedffc
- canonical_url
- https://medium.com/@ahrchen/ios-programmatic-custom-tableviewcells-with-stevia-e6a962dedffc
- author_url
- https://medium.com/@ahrchen
- status
- ok
- fetched_at
- 2026-07-29 07:39:48