Skip to content

Commit

Permalink
Removed hacky, dubious frame stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfalk committed Apr 18, 2014
1 parent a00ac2e commit 710c00a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 35 deletions.
25 changes: 0 additions & 25 deletions NORLabelNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -247,31 +247,6 @@ - (void)repositionSubNodesBasedOnParentPosition:(CGPoint)position {
}


#pragma mark - frame

- (CGRect)frame{
CGFloat largestWidth = 0;
for (SKLabelNode *childNode in self.subNodes) {
if (childNode.frame.size.width > largestWidth) {
largestWidth = childNode.frame.size.width;
}
}
CGRect frame = self.propertyStateholderNode.frame;
frame.size.width = largestWidth;
SKLabelNode *topNode = [self.subNodes firstObject];
CGFloat top = CGRectGetMaxY(topNode.frame);
SKLabelNode *bottomNode = [self.subNodes lastObject];
CGFloat bottom = CGRectGetMinY(bottomNode.frame);
CGFloat height = bottom - top;
if (height < 0) {
height *= -1;
}

frame.size.height = height;
return frame;
}


#pragma mark - property getters

-(NSUInteger)numberOfLines{
Expand Down
22 changes: 12 additions & 10 deletions NORLabelNodeTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ - (void)testThatSubnodesInheritsPropertiesFromParent{
}


//- (void)testThatChangingLineSpacingHasEffectOnFrameHeight{
// SKScene *scene = [SKScene sceneWithSize:[UIApplication sharedApplication].keyWindow.frame.size];
// NORLabelNode *threeLineNode = [self nodeWithThreeSubNodes];
// [scene addChild:threeLineNode];
//
// CGFloat originalHeight = CGRectGetHeight(threeLineNode.frame);
// threeLineNode.lineSpacing = 3.0;
// CGFloat changedHeight = CGRectGetHeight(threeLineNode.frame);
// XCTAssertNotEqual(originalHeight, changedHeight, @"The height of the frame should have changed after altering the linespacing");
//}
- (void)testThatChangingLineSpacingHasEffectOnFrameHeight{
SKScene *scene = [SKScene sceneWithSize:[UIApplication sharedApplication].keyWindow.frame.size];
NORLabelNode *threeLineNode = [self nodeWithThreeSubNodes];
[scene addChild:threeLineNode];
SKLabelNode *node = [SKLabelNode labelNodeWithFontNamed:@"Helvetica"];
node.text = @"blabla";

CGFloat originalHeight = CGRectGetHeight(threeLineNode.frame);
threeLineNode.lineSpacing = 3.0;
CGFloat changedHeight = CGRectGetHeight(threeLineNode.frame);
XCTAssertNotEqual(originalHeight, changedHeight, @"The height of the frame should have changed after altering the linespacing");
}


- (void) testThatDefaultFontSizeIsDefined{
Expand Down

0 comments on commit 710c00a

Please sign in to comment.