ios - Why does NSLog show screen width and screen height as 0? -
ios - Why does NSLog show screen width and screen height as 0? -
so wrote next piece of code, displays reddish square in middle, intended be. however, when "nslog"ed output of screen size of device onto console, found value 0. why that?
let container = uiview() allow redsquare = uiview() allow bluesquare = uiview() override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. allow screensize : cgsize = uiscreen.mainscreen().applicationframe.size allow screenwidth = screensize.width allow screenheight = screensize.height nslog("screenwidth = %f, screenheight = %f", screenwidth, screenheight); self.container.frame = cgrect(x: 50, y: 50, width: screenwidth-100, height: screenwidth-100) self.view.addsubview(container) // set reddish square frame // want bluish square have same position redsquare // lets reuse bluesquare.frame self.redsquare.frame = cgrect(x: 0, y: 0, width: screenwidth-100, height: screenwidth-100) self.bluesquare.frame = redsquare.frame // set background colors self.redsquare.backgroundcolor = uicolor.redcolor() self.bluesquare.backgroundcolor = uicolor.bluecolor() // add together redsquare // we'll add together bluesquare part of transition animation self.container.addsubview(self.redsquare) } ios swift
Comments
Post a Comment