Skip to content

Instantly share code, notes, and snippets.

@azuredark
azuredark / UserDefaultsManager.swift
Created August 11, 2023 05:41 — forked from amrangry/UserDefaultsManager.swift
UserDefaultsManager is a manager and wrapper class for UserDefaults
//
// UserDefaultsManager.swift
// Www.ADKATech.com
//
// Created by AmrAngry on 7/30/19.
// Modifyed by AmrAngry on 5/5/20.
// Copyright © 2019 Www.ADKATech.com. All rights reserved.
// Generic use original mestion by (FB)محمود زكى and hamada147(Github)
import Foundation
@azuredark
azuredark / CollectionViewInTableViewCell.swift
Created August 9, 2023 13:25 — forked from DonMag/CollectionViewInTableViewCell.swift
Basic Swift iOS example of collection view in a table view cell
// assign table view controller custom class to:
// DonMagSampleTableViewController
// no cell Prototypesneeded
// no @IBOutlet or @IBAction connections needed
struct DonMagSampleDataStruct {
var color: UIColor = .white
var strings: [String] = []
}
import UIKit
protocol DropDownButtonDelegate: AnyObject {
func didSelect(_ index: Int)
}
class DropDownButton: UIView {
let button: UIButton = {
let button = UIButton()
@azuredark
azuredark / ReloadTableVIew
Created July 9, 2023 14:09 — forked from gunantosteven/ReloadTableVIew
Reload UITableview when add new row
DispatchQueue.main.asyncAfter(deadline: .now() + 0.500) {
self.tableView.setNeedsLayout()
self.tableView.layoutIfNeeded()
self.tableView.reloadData()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.500) {
UIView.performWithoutAnimation {
let firstIndexPath = IndexPath(row: 0, section: 0)
self.tableView.reloadRows(at: [firstIndexPath], with: .none)
self.tableView.setContentOffset(CGPoint.zero, animated: true)
}
@azuredark
azuredark / ConstantAreaView.swift
Created July 7, 2023 13:05 — forked from pilot34/ConstantAreaView.swift
Dynamic intrinsicContentSize example
//
// ViewController.swift
// ConstantArea
//
// Created by Gleb Tarasov on 24.05.2020.
// Copyright © 2020 Gleb Tarasov. All rights reserved.
//
import UIKit
@azuredark
azuredark / gist:ef09830beabf2408addd1031b8996a68
Created July 6, 2023 19:17 — forked from markhorrocks/gist:0c366f06cdad8ef92871e2591bf8178d
Swift 3 iOS dynamic layout CollectionView cell all in code
This is a collection view of vertically scrolling cells 1/3 high as wide and left hand image 1/3 width of screen with text label 2/3 screen width to the right of the image. This is completely created in code. I created a View Controller on the storyboard as I needed to attach a navgation controller. All you ever ever need to adjust is the imageAspectRatio and te image will always be 1/3 of the width of the cell row.
ViewController code.
import UIKit
let imageAspectRatio : CGFloat = 1.2
//
// BottomSheetView.swift
//
// Created by Majid Jabrayilov
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
fileprivate enum Constants {
static let radius: CGFloat = 16
@azuredark
azuredark / QueryParms.swift
Created June 16, 2023 06:52 — forked from bhoopendraUmrao/QueryParms.swift
Get query parameters from URL in dictionary form.
func getQueryItems(_ urlString: String) -> [String : String] {
var queryItems: [String : String] = [:]
let components: NSURLComponents? = getURLComonents(urlString)
for item in components?.queryItems ?? [] {
queryItems[item.name] = item.value?.removingPercentEncoding
}
return queryItems
}
func getURLComonents(_ urlString: String?) -> NSURLComponents? {
@azuredark
azuredark / CollectionViewCellAutomaticsizeLeftAlign.swift
Created June 7, 2023 04:58 — forked from fomagran/CollectionViewCellAutomaticsizeLeftAlign.swift
컬렉션뷰셀 자동 크기 조정 및 왼쪽 정렬
import UIKit
class ViewController: UIViewController {
let letters = ["안녕","안녕하세요","안녕하세요 저는 포마입니다.","안녕하세요 만나서 정말 반갑습니다."]
@IBOutlet weak var collection: UICollectionView!
override func viewDidLoad() {
configure()
//
// TestimonyCollectionViewController.swift
// EMtrade
//
// Created by Fachruzi Ramadhan on 02/09/20.
// Copyright © 2020 Fachruzi Ramadhan. All rights reserved.
//
import UIKit