Skip to content

Instantly share code, notes, and snippets.

View geek1706's full-sized avatar
🏠
Working from home

Trung Nguyen geek1706

🏠
Working from home
View GitHub Profile
@geek1706
geek1706 / proxy_methods.m
Created June 17, 2018 03:02 — forked from marclove/proxy_methods.m
iOS 10.2 Appearance Proxy Methods
// iOS 10.2 APPEARANCE PROXY METHODS
// Generated thanks to Matt's gist: https://gist.github.com/mattt/5135521
// UIActivityIndicatorView
// ==========================
@property (nullable, readwrite, nonatomic, strong) UIColor *color NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
// UIBarButtonItem
// ==========================
(void)setBackgroundImage:(nullable UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
func print(_ items: Any...) {
#if DEBUG
Swift.print(items)
#else
repeat {} while 1 < 0
#endif
}
UIView.animate(withDuration: 0.3) {
self.arrowImageView.layer.transform = CATransform3DMakeRotation(CGFloat(Double.pi), 1.0, 0.0, 0.0)
}
UIView.animate(withDuration: 0.3) {
self.arrowImageView.layer.transform = CATransform3DMakeRotation(CGFloat(Double.pi), 0.0, 0.0, 0.0)
}
@geek1706
geek1706 / UITableView+Extension.swift
Last active July 6, 2018 11:12
Reusable View Protocols for UITableView swift 4
protocol ReusableView: class {}
extension ReusableView where Self: UIView {
static var reuseIdentifier: String {
return String(describing: self)
}
}
protocol NibLoadableView: class {}
@geek1706
geek1706 / TabBarController.swift
Last active July 24, 2018 01:44
Remove title of tab bar items and centering images
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// iOS 11: puts the titles to the right of image for horizontal size class regular. Only want offset when compact.
// iOS 9 & 10: always puts titles under the image. Always want offset.
var verticalOffset: CGFloat = 6.0
if #available(iOS 11.0, *), traitCollection.horizontalSizeClass == .regular {
verticalOffset = 0.0
}
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
let students = ["Kofi", "Abena", "Efua", "Kweku", "Akosua"]
let studentsByLetter = Dictionary(grouping: students, by: { $0.first! })
print(studentsByLetter)
// ["E": ["Efua"], "K": ["Kofi", "Kweku"], "A": ["Abena", "Akosua"]]
import UIKit
final class SearchViewController: UITableViewController {
private var searchController: UISearchController!
override func viewDidLoad() {
super.viewDidLoad()
searchController = UISearchController(searchResultsController: nil)
@geek1706
geek1706 / Podfile
Created August 14, 2018 09:27
fix failed to render and update auto layout status
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end
import ObjectMapper
class CustomDateTransform: TransformType {
static let dateFormatter: DateFormatter = {
let df = DateFormatter()
df.dateFormat = "yyyy-MM-dd"
return df
}()
~/Library/Developer/CoreSimulator/Devices