Skip to content

Instantly share code, notes, and snippets.

View CharlesAE's full-sized avatar
🎯
Focusing

Charles E CharlesAE

🎯
Focusing
View GitHub Profile
class TodayViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, NCWidgetProviding {
//Creating the collectionview and giving it some properties
let userCollectionView: UICollectionView = {
//The collectionView flow layout
let layout = UICollectionViewFlowLayout()
layout.minimumInteritemSpacing = 1.0
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.translatesAutoresizingMaskIntoConstraints = false
cv.backgroundColor = .clear
import UIKit
class UserCell: UICollectionViewCell {
//Creating the ImageView, assigning it an image from the assets folder
let userImage: UIImageView = {
let iv = UIImageView()
iv.contentMode = .scaleAspectFit
iv.image = #imageLiteral(resourceName: "user")
iv.translatesAutoresizingMaskIntoConstraints = false
return iv
import Foundation
import UIKit
extension UIView {
public func addConstraintsWithFormat(_ format: String, views: UIView...) {
var viewsDictionary = [String: UIView]()
for (index, view) in views.enumerated() {
let key = "v\(index)"
viewsDictionary[key] = view
//..
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Manually create the application window
window = UIWindow(frame: UIScreen.main.bounds)
//Custom theming on the application
UIApplication.shared.statusBarStyle = .lightContent
application.isStatusBarHidden = false
UINavigationBar.appearance().isTranslucent = false