ios - How do I make a border around my whole screen for all the devices in Swift Xcode? -


i have game thats in landscape , need border around whole screen heronode can't go out of screen on either of 4 sides. have code works iphone 5s , small other devices. how code resize , fit screen other devices? thanks!

        override func didmovetoview(view: skview) {     let borderbody = skphysicsbody(edgeloopfromrect: cgrect(x: 20, y: -90, width: self.size.width-50, height: self.size.height))     borderbody.categorybitmask = borderbodycategory     borderbody.collisionbitmask = herocategory     borderbody.contacttestbitmask = herocategory     borderbody.allowsrotation = false     borderbody.affectedbygravity = false     self.physicsbody = borderbody      } 

you can use uiscreen 's property instead of fixed value.

let width = uiscreen.mainscreen().bounds.size.width - 50 let height = uiscreen.mainscreen().bounds.size.height - 50 let borderbody = skphysicsbody(edgeloopfromrect: cgrect(x: 20, y: -90, width: width, height: height)) 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -