Use the centerRect
property of SKSpriteNode
. Assuming your texture is 50 pixels wide and you want not to stretch the leftmost and rightmost 10 pixels:
SKTexture *texture = [SKTexture textureWithImage:image];
SKSpriteNode *node = [SKSpriteNode spriteNodeWithTexture:texture size:CGSizeMake(150, 8)];
node.centerRect = CGRectMake(10 / 50.0, 0, 30 / 50.0, 1);
centerRect
is specified in unit coordinates of the texture. More info here under "Resizing a Sprite."