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 { | |
@IBOutlet weak var dom: UIButton! | |
@IBOutlet weak var seg: UIButton! | |
@IBOutlet weak var ter: UIButton! | |
@IBOutlet weak var qua: UIButton! | |
@IBOutlet weak var qui: UIButton! | |
@IBOutlet weak var sex: UIButton! | |
@IBOutlet weak var sab: UIButton! |
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
lazy var dias: [UIButton] = [dom, seg, ter, qua, qui, sex, sab] |
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 viewDidLoad() { | |
super.viewDidLoad() | |
dias[diaDaSemanaAtual].backgroundColor = UIColor.systemTeal | |
dias[diaDaSemanaAtual].titleLabel?.font = .systemFont(ofSize: 13, weight: .semibold) | |
calendario() | |
} |
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 viewDidLoad() { | |
super.viewDidLoad() | |
dias[diaDaSemanaAtual].backgroundColor = UIColor.systemTeal | |
dias[diaDaSemanaAtual].titleLabel?.font = .systemFont(ofSize: 13, weight: .semibold) | |
dom.tag = 1 | |
seg.tag = 2 | |
ter.tag = 3 | |
qua.tag = 4 | |
qui.tag = 5 |
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 calendario() { | |
var diaDepois = diaAtual | |
var diaAntes = diaAtual | |
for dia in diaDaSemanaAtual ... 6 { //Para saber qual é o próximo dia | |
dias[dia].setTitle("\(diaDepois)", for: .normal) | |
switch mesAtual { | |
case 1, 3, 5, 7, 8, 10, 12: //Meses com 31 dias | |
if diaDepois == 31 { | |
diaDepois = 1 |
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 calendario() { | |
var diaDepois = diaAtual | |
var diaAntes = diaAtual | |
for dia in diaDaSemanaAtual ... 6 { //Para saber qual é o próximo dia | |
dias[dia].setTitle("\(diaDepois)", for: .normal) | |
switch mesAtual { | |
case 1, 3, 5, 7, 8, 10, 12: //Meses com 31 dias | |
if diaDepois == 31 { | |
diaDepois = 1 |
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
dias[diaDaSemanaAtual].backgroundColor = UIColor.systemTeal | |
dias[diaDaSemanaAtual].titleLabel?.font = .systemFont(ofSize: 13, weight: .semibold) |
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 diaDaSemanaAtual = Calendar.current.component(.weekday, from: Date())-1 | |
//Este é o valor que irá nos mostrar em que dia da semana estamos (Ex: segunda, terça, etc). | |
//O -1 é necessário para igualar as posições do dia com as posições dos botões no vetor | |
var diaAtual = Calendar.current.component(.day, from: Date()) | |
//Dia atual (Ex: 1, 2, 31, etc). | |
var mesAtual = Calendar.current.component(.month, from: Date()) | |
//Mês atual (Ex: janeiro, fevereiro, etc). | |
//Esse valor é necessário para verificarmos o número de dias de cada mês |
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 viewDidLoad() { | |
super.viewDidLoad() | |
dom.tag = 1 | |
seg.tag = 2 | |
ter.tag = 3 | |
qua.tag = 4 | |
qui.tag = 5 | |
sex.tag = 6 | |
sab.tag = 7 |
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 { | |
@IBOutlet weak var dom: UIButton! | |
@IBOutlet weak var seg: UIButton! | |
@IBOutlet weak var ter: UIButton! | |
@IBOutlet weak var qua: UIButton! | |
@IBOutlet weak var qui: UIButton! | |
@IBOutlet weak var sex: UIButton! | |
@IBOutlet weak var sab: UIButton! |
NewerOlder