This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No MotorcycleTableViewCell | |
class MotorcycleTableViewCell: UITableViewCell { | |
static var height: CGFloat { | |
return 80 | |
} | |
static var identifier: String { | |
return String(describing: self) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func setupViews() { | |
contentView.addSubview(imgView) | |
contentView.addSubview(titleLabel) | |
contentView.addSubview(subtitleLabel) | |
imgView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 16).isActive = true | |
imgView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16).isActive = true | |
imgView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -16).isActive = true | |
imgView.widthAnchor.constraint(equalTo: imgView.heightAnchor).isActive = true | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private let imgView: UIImageView = { | |
let iv = UIImageView() | |
iv.translatesAutoresizingMaskIntoConstraints = false | |
iv.contentMode = .scaleAspectFit | |
iv.clipsToBounds = true | |
return iv | |
}() | |
private let titleLabel: UILabel = { | |
let label = UILabel() | |
label.translatesAutoresizingMaskIntoConstraints = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private let imgView: UIImageView = { | |
return UIImageView() | |
}() | |
private let titleLabel: UILabel = { | |
return UILabel() | |
}() | |
private let subtitleLabel: UILabel = { | |
return UILabel() | |
}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [...] | |
private let imgView = UIImageView() | |
private let titleLabel = UILabel() | |
private let subtitleLabel = UILabel() | |
// [...] | |
private func setupViews() { | |
contentView.addSubview(imgView) | |
contentView.addSubview(titleLabel) | |
contentView.addSubview(subtitleLabel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MotorcycleTableViewCell: UITableViewCell { | |
var motorcycle: Motorcycle? | |
override init(style: UITableViewCellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
setupViews() | |
} | |
required init?(coder aDecoder: NSCoder) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
private let motorcycles: [Motorcycle] | |
private lazy var tableview: UITableView = { | |
let tableview = UITableView() | |
tableview.translatesAutoresizingMaskIntoConstraints = false | |
tableview.dataSource = self | |
tableview.contentInset = UIEdgeInsets(top: 16, left: 0, bottom: 16, right: 0) | |
return tableview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Motorcycle { | |
let image: UIImage | |
let name: String | |
let type: MotorcycleType | |
} | |
enum MotorcycleType: String { | |
case sport = "Sport bike" | |
case bigTrail = "Big Trail" | |
case custom = "Custom" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.backgroundColor = .white | |
// [...] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// Monta a window de acordo com o tamanho da tela | |
window = UIWindow(frame: UIScreen.main.bounds) | |
// Instancia o ViewController | |
let vc = ViewController() | |
// Bota como tela principal dentro de uma navigationController | |
window?.rootViewController = UINavigationController(rootViewController: vc) | |
// Faz a window ser exibida | |
window?.makeKeyAndVisible() | |
return true |
NewerOlder