Skip to content

Instantly share code, notes, and snippets.

import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView {
VStack{
CardViewItem()
}
.padding()
@jamestapping
jamestapping / replaceOccurences.swift
Last active June 25, 2021 06:24
replaceOccurences.swift
let url = (films[indexPath.row].artworkUrl100)!
let modifiedUrl = url.replacingOccurrences(of: "100x100", with: "800x800")
var url = (films[indexPath.row].artworkUrl100)!
url.removingRegexMatches(pattern: "100x100", replaceWith: "800x800")
import Foundation
extension String {
mutating func removingRegexMatches(pattern: String, replaceWith: String = "") {
do {
let regex = try NSRegularExpression(pattern: pattern, options: .caseInsensitive)
let range = NSRange(location: 0, length: count)
self = regex.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: replaceWith)
} catch { return }
}
@jamestapping
jamestapping / gist:3e7d09e3a1cb27d19c21b28e71194e39
Created June 14, 2021 16:51
UITextField+SecureToggle.swift
import Foundation
import UIKit
let button = UIButton(type: .custom)
extension UITextField {
func enablePasswordToggle(){
button.setImage(UIImage(named: "icons8-open-eye-48"), for: .normal)
import UIKit
class TableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: - Table view data source
@jamestapping
jamestapping / TextViewCell.swift
Created April 2, 2021 14:49
Medium TableView TextView example - TextViewCell.swift
import UIKit
protocol TextViewCellDelegate {
func updateCellHeight()
}
class TextViewCell: UITableViewCell {
var delegate: TextViewCellDelegate?
@jamestapping
jamestapping / gist:f981c7453f25b54c02d305377592c79d
Created March 4, 2021 15:38
Tick Cross toggle Animated Button
//
// TickCrossToggle.swift
// UIButtons
//
// Created by James Tapping on 04/03/2021.
//
import Foundation
import UIKit
@jamestapping
jamestapping / gist:2fcd3b03b484923a94d0d57971a5472e
Last active March 4, 2021 14:23
Animated UIButton image array creation
func setUpAnimatedFramesButton() {
var imagesListArray :[UIImage] = []
for position in 0...27
{
let strImageName : String = "icons8-cancel-\(position)"
let image = UIImage(named:strImageName)
imagesListArray.append(image!)
}