Skip to content

Instantly share code, notes, and snippets.

class CustomCollectionViewCell: UICollectionViewCell{
override var isSelected: Bool{
//Write your code for cell selection here
}
}
override var isSelected: Bool{
didSet{
}
}
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)
}
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
{
var sharedContainer = UserDefaults(suiteName: "YOUR_GROUP_NAME")
override func viewDidLoad()
{
super.viewDidLoad()
self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded
}
func widgetPerformUpdate(completionHandler: @escaping (NCUpdateResult) -> Swift.Void)
{
completionHandler(.newData)
}
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize)
{
if activeDisplayMode == .expanded
{
preferredContentSize = CGSize(width: 0.0, height: 300.0)
}
else
{
preferredContentSize = maxSize
}
self.extensionContext?.open(URL(string: "YOUR_URL_SCHEME://")!, completionHandler: nil)
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
}