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
import UIKit | |
class ViewController: UIViewController { | |
let titleLabel: UILabel = { | |
let label = UILabel() | |
label.text = "Hello Constraints" | |
label.backgroundColor = .red | |
label.translatesAutoresizingMaskIntoConstraints = false | |
return label |
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
import Cartography | |
private func setupWithCartography() { | |
view.addSubview(titleLabel) | |
view.addSubview(hiButton) | |
constrain(titleLabel, view) { label, superview in | |
label.top == superview.top + 20 | |
label.leading == superview.leading + 20 | |
label.trailing == superview.trailing - 20 |
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 setupAnchorConstraints() { | |
view.addSubview(titleLabel) | |
view.addSubview(hiButton) | |
titleLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 20).isActive = true | |
titleLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).isActive = true | |
titleLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20).isActive = true | |
hiButton.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 8).isActive = true | |
hiButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20).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 func setupNSLayoutConstraints() { | |
view.addSubview(titleLabel) | |
view.addSubview(hiButton) | |
let labelVerticalConstraint = NSLayoutConstraint.init(item: titleLabel, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 20) | |
let labelLeadingConstraint = NSLayoutConstraint.init(item: titleLabel, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: 20) | |
let labelTrailingConstraint = NSLayoutConstraint.init(item: titleLabel, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailing, multiplier: 1, constant: -20) | |
let buttonVerticalConstraint = NSLayoutConstraint.init(item: hiButton, attribute: .top, relatedBy: .equal, toItem: titleLabel, attribute: .bottom, multiplier: 1, constant: 8) | |
let buttonLeadingConstraint = NSLayoutConstraint.init(item: hiButton, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: 20) |
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 setupVisualConstraints() { | |
view.addSubview(titleLabel) | |
view.addSubview(hiButton) | |
let viewsDict = [ | |
"label": titleLabel, | |
"button": hiButton | |
] | |
let verticalConstraint = NSLayoutConstraint.constraints( |
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
# | |
# Be sure to run `pod spec lint uFeature.podspec' to ensure this is a | |
# valid spec and to remove all comments including this before submitting the spec. | |
# | |
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html | |
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ | |
# | |
Pod::Spec.new do |s| | |
s.name = 'uFeature' |
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
- (NSString *)getName { | |
return @"Yasmin Benatti"; | |
} | |
- (void)helloWorld { | |
NSLog(@"Hello %@", [self getName]); | |
} | |
[self helloWorld]; |
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 getName() -> String { | |
return "Yasmin Benatti" | |
} | |
func helloWorld() { | |
print("Hello " + getName()) | |
} | |
helloWorld() |
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
extension ViewController : UITableViewDelegate { | |
//1 - método chamado quando uma linha é selecionada | |
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
tableView.deselectRow(at: indexPath, animated: true) | |
} | |
//2 - método para definir a altura de cada linha | |
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | |
return 44 | |
} |
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
extension ViewController : UITableViewDataSource { | |
//1 - primeiro método obrigatório | |
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return 10 | |
} | |
//2 - segundo método obrigatório | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
//3 - crie uma célula com o mesmo identificador de quando registramos a classe | |
let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) |
NewerOlder