Skip to content

Instantly share code, notes, and snippets.

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

Dino brascene

🏠
Working from home
  • Ministry of Programming
  • Sarajevo
View GitHub Profile
@brascene
brascene / fib.swift
Last active March 12, 2023 09:10
Get n-th fibonacci number in Swift
import Foundation
import CoreFoundation
// MARK: Without recursion
func fib(_ n: Int) -> Int {
guard n > 1 else { return n }
var arr = Array.init(repeating: 1, count: n)
for i in 2..<n {
arr[i] = arr[i - 1] + arr[i - 2]
}
@brascene
brascene / CustomPageControl.swift
Created July 13, 2018 07:48
Custom UIPageControl for replacing the default circles with desired icons
class CustomPageControl: UIPageControl {
// active and inactive images
let imgActive: UIImage = #imageLiteral(resourceName: "activeImage").withRenderingMode(.alwaysTemplate)
let imgInactive: UIImage = #imageLiteral(resourceName: "inactiveImage")
// adjust these parameters for specific case
let customActiveYOffset: CGFloat = 5.0
let customInactiveYOffset: CGFloat = 3.0
var hasCustomTintColor: Bool = false
let customActiveDotColor: UIColor = UIColor(rgb: 0xe62f3e, alphaVal: 1.0)
@brascene
brascene / LargeTitleCustomOffset.swift
Last active February 25, 2022 09:36
Navigation bar large title custom y offset - iOS 11
import UIKit
class LargeTitleCustomOffset: UINavigationBar {
let labelcolor = UIColor(red: 36.0/255.0, green: 38.0/255.0, blue: 47.0/255.0, alpha: 1.0)
override func draw(_ rect: CGRect) {
super.draw(rect)
self.backgroundColor = UIColor.white