SKPhysicsBody and [SKNode setScale:]

Using either an SKAction or the Update loop, you can create a new SKPhysicsBody with the proper scale and apply it to the object. However, by doing so, you will lose the velocity. To fix this, you can do the following: SKPhysicsBody *newBody = [SKPhysicsBody bodyWithRectangleOfSize:boxObject.size]; newBody.velocity = boxObject.physicsBody.velocity; boxObject.physicsBody = newBody;

How to add CSS for HTML to NSAttributedString?

Since iOS 7 you can use NSAttributedString with HTML syntax: NSURL *htmlString = [[NSBundle mainBundle] URLForResource: @”string” withExtension:@”html”]; NSAttributedString *stringWithHTMLAttributes = [[NSAttributedString alloc] initWithFileURL:htmlString options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil]; textView.attributedText = stringWithHTMLAttributes; // attributedText field! You have to add string.html to you project, and the content of the html can be like this: <html> <head> <style type=”text/css”> … Read more

Zooming and scrolling in SpriteKit

Here is my solution to the scrolling problem. It revolves around “stealing” the behaviour from the UIScrollView. I learned this from a WWDC Video from 2012 about mixing UIKit with OpenGL. Add the UIScrollViewDelegate methods to your ViewController and set the scroll view delegate to the ViewController Add/Move the PanGestureRecognizer from the UIScrollView to the … Read more

iOS 7 BUG – NSAttributedString does not appear

I have found a workaround for this bug. In your github code, to use the workaround, you would say this: NSAttributedString* attrStr = [[NSAttributedString alloc] initWithString:@”Lorem ipsum dolor sit\n” // <— attributes: @{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle), NSParagraphStyleAttributeName:paragraph}]; UILabel* myLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 0, 0)]; myLabel.backgroundColor = [UIColor greenColor]; myLabel.attributedText = attrStr; [myLabel sizeToFit]; myLabel.numberOfLines = 2; … Read more

Cannot set text color of Send and Cancel buttons in the mail composer when presented from the UIActivityViewController in iOS7

Managed to change the text color of the Send and Cancel buttons, which are on the UINavigationBar in the MFMailComposerViewController (both Send and Cancel) and MFMessageComposeViewController (only Cancel), when presented from UIActivityViewController. Using an UIActivityViewController, tap on Messageor Mail: You’ll notice that the default text color of the Send and Cancel buttons is blue: In … Read more

Access Asset Catalog pathForResource

Same problem, but I don’t think we could access it via pathForResource:, except below: UIImage* image = [UIImage imageNamed:@”name-in-asset-catalog”]; It has been clearly documented: Each set in an asset catalog has a name. You can use that name to programmatically load any individual image contained in the set. To load an image, call the UIImage:imageNamed: … Read more

Is there a way since (iOS 7’s release) to get the UDID without using iTunes on a PC/Mac?

Navigate to from Safari on your iOS device. It works like a charm and requires neither iTunes nor any other computer. No app installed either. EDIT: Also, have a look at Getting a device UDID from .mobileconfig if you (understandably) would rather have this .mobileconfig certificate hosted on a server of yours. MAKE YOUR … Read more