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
//Encontrar o menor e o maior valor em values | |
guard let maxValue = values.max() else { return } | |
guard let minValue = values.min() else { return } | |
values.forEach { (value) in | |
// Agora sabemos que o gráfico tem dois comportamentos para se normalizar, um deles se o menor valor for 0 e outro se o menor valor for diferente de 0. A lógica é a mesma em ambos, a diferença agora é a variação dos valores. | |
if minValue == 0 { | |
normalizedValue = 1-((maxValue-value)/(maxValue-minValue)) |
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
//Encontrar o menor e o maior valor em values | |
guard let maxValue = values.max() else { return } | |
guard let minValue = values.min() else { return } | |
values.forEach { (value) in | |
//Normalizando os dados | |
let normalizedValue = 1-((maxValue-value)/(maxValue-minValue)) | |
//Lembrando que posY agora é metade da altura da view - a altura da barra |
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
var posX: CGFloat = 0.0 | |
var barWidth: CGFloat = 30.0 | |
values.forEach { (value) in | |
let posY = bounds.height/2 - value | |
let bar = CGRect(x: posX, y: posY, width: barWidth, height: value) | |
context.addRect(bar) |
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
var values = [CGFloat]() | |
for i in 0...10 { | |
values.append(CGFloat(i)) | |
} |
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
let bar = CGRect(x: bounds.width/2, y: bounds.height/2, width: 100.0, height: 100.0) | |
context.addRect(bar) | |
context.setFillColor(UIColor.red.cgColor) | |
context.fillPath() |
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
guard let context = UIGraphicsGetCurrentContext() else { return } |
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
email me at eloisamariafalcao@gmail.com |
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
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TableViewCell | |
cell.imagemCelula.image = UIImage(named: foto[indexPath.row]) | |
cell.nomeCelula.text = seteMaravilhas[indexPath.row] | |
cell.paisCelula.text = paises[indexPath.row] | |
cell.view.backgroundColor = #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 0.6) | |
return cell | |
} |
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
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return seteMaravilhas.count | |
} | |
NewerOlder