I created a rectangle using CGRect, but I can't seem to center it relative to the frame size. And when setting the x and y values to 0, it would end up in the right-center (not exactly centered, actually, unless it's calculated by the bottom end of the object) end of the screen, rather than the actual center or the left corner. So how would I make point 0, 0 be at the center of the screen, if possible, and how would I center my shape at the (bottom) middle of the screen relative to the frame size?import PlaygroundSupport
import SpriteKit
class GameScene: SKScene {
var textBackground = SKShapeNode(rect: .zero)
override func didMove(to view: SKView) {
textBackground = SKShapeNode(rect: CGRect(x: 0, y: 0, width: frame.size.width - 300,
height: frame.size.height / 6))
textBackground.fillColor = SKColor.init(red: 255, green: 255, blue: 255, alpha: 0.5)
textBackground.strokeColor = SKColor.clear
addChild(textBackground)
}
@objc static override var supportsSecureCoding: Bool {
get {
return true
}
}
override func update(_ currentTime: TimeInterval) {
}
}
let sceneView = SKView(frame: CGRect(x: 0 , y:0, width: 1024, height: 1366))
if let scene = GameScene(fileNamed: "GameScene") {
// scene.scaleMode = .aspectFill
sceneView.presentScene(scene)
}
PlaygroundSupport.PlaygroundPage.current.liveView = sceneViewAlso, my shape width also looks off since I wanted it to cover almost the width of the whole screen except for the ends, so using the frame width and cutting it short a few points was what I thought would be the best way to do it. Only subtracting 300 points was the only way I could get it to work, which looks like a bit too much, so I'm wondering if my view's whole x-coordinates are somehow off?Any help would be greatly appreciated. Thank you.
Post
Replies
Boosts
Views
Activity
Whenever I use Xcode, the notification "iMessage is no longer available on this device" constantly pops up. Additionally, my MacBook has a restriction on Messages via an MDM profile, which would explain why I get the notification, but not why I get it whenever I'm using Xcode. So is there any way I can prevent the notification from constantly popping up while using Xcode without actually removing the profile?Thank you.
Whenever I try to type something on Swift Playgrounds, it keeps unselecting the text area. However, the issue appears to temporarily disappear whenever I open the Developer Documentation, only to reoccur as soon as I switch pages. Is this a bug on the app or a bug on my Mac? And is there any way to resolve the issue?Thank you.
Swift Playgrounds overheats my MacBook within 5-10 min of opening the app, even if I don't do anything on it and simply leave it open. Does anyone else have this issue? And is there anyway to prevent it from overheating so quickly, or should I just wait for the next update?Thank you.