Skip to content

Instantly share code, notes, and snippets.

View rockbruno's full-sized avatar

Bruno Rocha rockbruno

View GitHub Profile
var myView: MyView {
return view as! MyView
}
final class MyViewController: UIViewController {
override func loadView() {
let myView = MyView()
myView.delegate = self
view = myView
}
override func viewDidLoad() {
super.viewDidLoad()
print(view) // Uma instância de 'MyView'!
final class MyViewController: UIViewController {
   
let myView = MyView()
 
override func viewDidLoad() {
super.viewDidLoad()
setupMyView()
}
 
private func setupMyView() {
final class MyViewController: UIViewController {
private let myButton: UIButton = {
//
}()
 
private let myView: UIView = {
//
}()
 
//Mais umas 10 views aqui...
@rockbruno
rockbruno / UIButton+DualLabel.swift
Last active September 7, 2018 06:30
"Native" Dual Label UIButton
extension UIButton {
/// Sets an UIButton's left and right title separated by invisible spaces, to give the impression of having two labels
/// without losing native UIButton properties, such as animations that come with the .system button type.
/// Requires tintColor to match the button's title color.
func setDualTitle(left: String, right: String, horizontalMargin: CGFloat = 8) {
let columnCount = (UIScreen.main.bounds.width - (horizontalMargin * 2)) * 0.2
let columns = String(repeating: "|", count: Int(columnCount))
let attributedString = NSMutableAttributedString(string: left, attributes: [.foregroundColor: tintColor])
attributedString.append(NSAttributedString(string: columns, attributes: [.foregroundColor: UIColor.clear]))
attributedString.append(NSAttributedString(string: right, attributes: [.foregroundColor: tintColor]))
@rockbruno
rockbruno / AccountKitForceLocalization.rb
Created July 13, 2017 13:22
iOS Account Kit script to force localization
# Bruno Rocha
# Add this file to your {SRCROOT}/bin, change ptProj to your desired locale
# and then add a Run Script at Xcode with this:
# ruby $SRCROOT/bin/AccountKitForceLocalization.rb
require 'find'
require 'uri'
require 'fileutils'
$scriptPath = File.dirname(__FILE__)