View UIColor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Extension to make it easy for UIColor init | |
extension UIColor { | |
convenience init(red: Int, green: Int, blue: Int) { | |
let newRed = CGFloat(red)/255 | |
let newGreen = CGFloat(green)/255 | |
let newBlue = CGFloat(blue)/255 | |
self.init(red: newRed, green: newGreen, blue: newBlue, alpha: 1.0) | |
} | |
} |
View UITableViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DashboardCell: UITableViewCell { | |
// MARK: - Properties | |
static let reuseIdentifier = "DashboardCell" | |
// MARK: - | |
@IBOutlet weak var lblHeaderTitle: UILabel! | |
//@IBOutlet weak var imgContactDetails: UIImageView! | |
@IBOutlet weak var lblDetail1: UILabel! |
View Swift 4 - Address form String.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func map(address: String, title: String, name: String) { | |
let location = address | |
let geocoder = CLGeocoder() | |
geocoder.geocodeAddressString(location) { [weak self] placemarks, error in | |
if let placemark = placemarks?.first, let location = placemark.location { | |
let mark = MKPlacemark(placemark: placemark) | |
let coordinates:CLLocationCoordinate2D = placemark.location!.coordinate | |
if var region = self?.mapView.region { | |
region.center = location.coordinate |
View MapKitView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContactMapView.swift | |
import UIKit | |
import MapKit | |
import Contacts | |
import CoreLocation | |
var addressString = "" //Pass Address String from other View Controllers |
View UITableviewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? { | |
let indexPathIndex = tableView.indexPathForSelectedRow | |
let indexPath = indexPathIndex?.row ?? 0 | |
let callButton = UITableViewRowAction(style: .normal, title: "📞\n Call") { action, index in | |
print("call button tapped") | |
let number = data[indexPath].phone ?? "" | |
print("Number: " + number) | |
UIApplication.makeAPhoneCall(number: number.replacingOccurrences(of: "-", with: "")) |
View MapKitMinimal.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import MapKit | |
class MapViewController: UIViewController, MKMapViewDelegate { | |
@IBOutlet var mapView: MKMapView! | |
var restaurant: RestaurantMO! | |
override func viewDidLoad() { |
View UITextField.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://github.com/hackiftekhar/IQKeyboardManager | |
Extremely easy to install Swift or Objective-C. | |
Here how it works: | |
IQKeyboardManager (Swift):- IQKeyboardManagerSwift is available through CocoaPods, to install it simply add the following line to your Podfile: (#236) | |
*/ | |
// pod 'IQKeyboardManagerSwift' | |
//In AppDelegate.swift, just import IQKeyboardManagerSwift framework and enable IQKeyboardManager. |
View States.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//States | |
let states = [ "AK","AL","AR","AS","AZ","CA","CO","CT","DC","DE","FL","GA","GU","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","PR","RI","SC","SD","TN","TX","UT","VA","VI","VT","WA","WI","WV","WY"] |
View Contacts.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ContactsUI | |
import UIKit | |
class ViewController: UIViewController, CNContactPickerDelegate { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
openAddressbook(vc: ViewController()) | |
} | |
View CoreDataOrderSave.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Override to support rearranging the table view. | |
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) { | |
if let appDel = (UIApplication.shared.delegate as? AppDelegate) { | |
let contxt = appDel.persistentContainer.viewContext | |
RefreshCoredata() | |
if fromIndexPath.row > to.row | |
{ | |
for i in to.row..<fromIndexPath.row | |
{ | |
songs[i].setValue(i+1, forKey: "orderPosition") |
OlderNewer