https://www.codeproject.com/Tips/1101832/Tree-View-in-Swift-For-iOS
Tuesday, 29 August 2017
Thursday, 3 August 2017
Longpress event in swift 3
override func viewDidLoad() {
super.viewDidLoad()
var longPressGesture : UILongPressGestureRecognizer!
longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(MainView.handleLongGesture))
self.view?.addGestureRecognizer(longPressGesture)
}
func handleLongGesture() {
print("long press")
// do Actions
}
}
Wednesday, 2 August 2017
Solve Gradient covers the background view in swift 3
Apply Gradient to View
class Testing: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
setGradientBackground()
}
func setGradientBackground() {
let colorTop = UIColor(red: 255.0/255.0, green: 149.0/255.0, blue: 0.0/255.0, alpha: 1.0).cgColor
let colorBottom = UIColor(red: 255.0/255.0, green: 94.0/255.0, blue: 58.0/255.0, alpha: 1.0).cgColor
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [ colorTop, colorBottom]
gradientLayer.locations = [ 0.0, 1.0]
gradientLayer.frame = self.view.bounds
self.view.layer.addSublayer(gradientLayer) // --> This will hides the background view
}
-->Some times it will apply full view, better to apply gradient in viewDidLoad()
replace
self.view.layer.addSublayer(gradientLayer)
with self.view.layer.insertSublayer(gradientLayer, at: 0)
, this will put the layer "below" all others --------------------------------------------------------------------------------------------------------------
background gradient to fill Landscape mode
-> some times gradient view will not cover total view when rotate screen .
we can solve this one to add below code
override func willAnimateRotation(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {
self.view.layer.sublayers?.first?.frame = self.view.bounds
}
Subscribe to:
Posts (Atom)
Remove bottom line in navigation bar
navigationController ?. navigationBar . setBackgroundImage ( UIImage (), for: . any , barMetrics: . default ) navigat...
-
--> Use this line for getting device name UIDevice.current.name ------------------------------------------------------------------...
-
For Label: labelname.attributedText = NSAttributedString(string: "text " , attributes: [NSUnderlineStyleAttribut...
-
// Reading data from Local Json file instead of Service urls using Alamofire in swift3 func getwordmeaningdata() { ...