Saturday, June 1, 2024
HomeiOS Developmentios - UIKIT: Lower Peak of Push Notification programmatically

ios – UIKIT: Lower Peak of Push Notification programmatically


enter image description hereI’ve NotificationViewController which was created once I applied Notification Content material Extension after which I removed the storyboard so I might programmatically make the view. Nevertheless I am having bother really lowering the peak of the particular push notification when the person does a protracted press. I believed the view represented the notification itself however it would not? I used to be in a position to change the peak of the notification on storyboard however I am have a tough time doing it programatically. Any assist can be nice!

import UIKit
import UserNotifications
import UserNotificationsUI

/// A View Controller that's activated when a push notification is pressed for some time.
class NotificationViewController: UIViewController, UNNotificationContentExtension {
    /// The label that shows the title of the push notification
    non-public lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.textColor = .black
        label.backgroundColor = .inexperienced
        label.textAlignment = .middle
        label.isHidden = false
        label.body = CGRect(x: 100, y: 0, width: 100, top: 100)
        return label
    }()

    override func loadView() {
        self.view = UIView(body: .zero)
        view.backgroundColor = .crimson
        view.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview(titleLabel)

        NSLayoutConstraint.activate([
            view.heightAnchor.constraint(equalToConstant: 100),
            view.widthAnchor.constraint(equalToConstant: 100 * 5),
        ])
    }

    func didReceive(_ notification: UNNotification) {
        let content material = notification.request.content material
        self.titeLabel.textual content = content material.physique
    }

}



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments