Skip to content

Instantly share code, notes, and snippets.

Avatar

Payal Gupta pgpt10

  • Delhi
View GitHub Profile
View collectionView_selection_1.swift
class CustomCollectionViewCell: UICollectionViewCell{
override var isSelected: Bool{
//Write your code for cell selection here
}
}
View collectionView_selection_3.swift
override var isSelected: Bool{
didSet{
if self.isSelected
{
//This block will be executed whenever the cell’s selection state is set to true (i.e For the selected cell)
}
else
{
//This block will be executed whenever the cell’s selection state is set to false (i.e For the rest of the cells)
}
View collectionView_selection_4.swift
override var isSelected: Bool{
didSet{
if self.isSelected
{
self.transform = CGAffineTransform(scaleX: 1.1, y: 1.1)
self.contentView.backgroundColor = UIColor.red
self.tickImageView.isHidden = false
}
else
{
View today_extension_1.swift
var sharedContainer = UserDefaults(suiteName: "YOUR_GROUP_NAME")
View today_extension_2.swift
override func viewDidLoad()
{
super.viewDidLoad()
self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded
}
View today_extension_3.swift
func widgetPerformUpdate(completionHandler: @escaping (NCUpdateResult) -> Swift.Void)
{
completionHandler(.newData)
}
View today_extension_4.swift
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize)
{
if activeDisplayMode == .expanded
{
preferredContentSize = CGSize(width: 0.0, height: 300.0)
}
else
{
preferredContentSize = maxSize
}
View today_extension_5.swift
self.extensionContext?.open(URL(string: "YOUR_URL_SCHEME://")!, completionHandler: nil)
View today_extension_6.swift
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
{
if url.scheme == "YOUR_URL_SCHEME"
{
//TODO: Write your code here
}
return true
}