objective c - Switching background according to time -
So I have seen the stack overflow for how to change the background image according to the current time with the IF statement; NSDateComponents:
NSDateComponents * Component = [NSDateComponents new]; // AM NSInteger Hour06 = 6; // 1 Hourly Morning NSING Hour 0 8 = 8; // 2 morning NSInteger hour 11 = 11; // 3 light mornings // PM NSInteger Hour12 = 12; // 4Epionian NSINGG16 = 16; // 5LateAfternoon NSInteger hour 18 = 18; // 6 nsintester hour 20 = 20; // 7LateEvening NSInteger Hour21 = 21; // 8 Night NSINTV Hour 23 = 23; // 9 light knight if (components; hour & lt; hour 18) {self.backgroundImage = [SKSpriteNode spriteNodeWithImageNamed: @ "6Evening"]; Self.backgroundImage.position = CGPointMake (auto size.width / 2, self size. HEIGHT / 2); Self.backgroundImage.zPosition = 0.0; // Default bottom position [auto addChild: self.backgroundImage]; } But the image is not changed. I have read this & amp; It did not help either. Can anyone tell me what I am missing?
My self & amp; YvesLeBorg got the answer! The following tasks if you are using SKVU due to the Spit Kit:
- (zero) background {NSDateComponents * components = [NSDateComponents new]; NSInteger Hour 18 = 18; // 6 if selecting (components.- hour> hour 18) {self.backgroundImage = [SKSpriteNode spriteNodeWithImageNamed: @ "6Evening"]; Self.backgroundImage.position = CGPointMake (auto size.width / 2, self size. HEIGHT / 2); Self.backgroundImage.zPosition = 0.0; // Default bottom position [auto addChild: self.backgroundImage]; }}
Comments
Post a Comment