2014-09-30 10 views
1

는 여기에 대답 다음 :사용자 지정 NSTextField의 크기와 글꼴을 변경하는 방법?

https://stackoverflow.com/a/3233802/3850487

내가 @ 데이브 코드를 사용할 수 있었고 그것을 잘 작동합니다.

유일한 방법은 내 레이블의 글꼴이나 크기를 변경하는 방법을 찾지 못하는 것입니다.

[self.rssLabel setText:fullString]; 
[self.rssLabel setSpeed:0.03f]; 
[[self rssLabel] setFont:[NSFont boldSystemFontOfSize:100]];//NOT WORKING 

아무런 변화가 없습니다. 영향을받지 않는 것과 같습니다. 내가 - (void)drawRect:(NSRect)dirtyRect 나는 데이브에게 연락을 시도

- (void)drawRect:(NSRect)dirtyRect { 
    // Drawing code here. 
    [[NSColor grayColor] set];//changed the background of the view 
    NSRectFill(dirtyRect); //not text color 
    ... 

} 

에 몇 가지 코드를 추가 할 때

내가 가진 가장 가까운

는했지만, 아직, 알려 주시기 바랍니다 말씀 드릴 수 없습니다.

답변

0

맞아요. drawRect:(NSRect)dirtyRect에서 변경해야합니다.

예 :

- (void)drawRect:(NSRect)dirtyRect { 
    // Drawing code here. 
    NSFont *font = [NSFont fontWithName:@"Courier" size: 15.0f]; 
    //add more custom stuff, then assign attributes 
    NSDictionary *attributes = @{ NSFontAttributeName: font}; 

    if (point.x + stringWidth < 0) { 
     point.x += dirtyRect.size.width; 
    } 

    [text drawAtPoint:point withAttributes:attributes];//assign! 

    if (point.x < 0) { 
     NSPoint otherPoint = point; 
     otherPoint.x += dirtyRect.size.width; 
     [text drawAtPoint:otherPoint withAttributes:attributes];//assign! 
    } 
}