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] = []
}
@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()
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 / ViewWithDynamicWidthScrollingView.swift
Created July 7, 2023 13:08 — forked from crisbit/ViewWithDynamicWidthScrollingView.swift
How to make a dynamic height scroll view programmatically in swift (using SnapKit)
import Foundation
class ViewWithDynamicWidthScrollingView: UIView {
convenience init() {
self.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height))
}
override init(frame: CGRect) {
super.init(frame: frame)
@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 / 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