0

I have problem with my project on Mac OS. I have a textfield, I want to change size it automatically when textfield is editing!Please suggest me a way to solve this. Thanks so much!

4

1 回答 1

0

您需要将对象设置为NSTextField. 作为NSTextField的子类NSControl,如果您实现它,它将调用-controlTextDidChange:您对象上的方法。

@interface MyObject : NSObject
{
    IBOutlet NSTextField* textField;
}
@end

@implementation MyObject
- (void)awakeFromNib
{
    [textField setDelegate:self];
}

- (void)controlTextDidChange:(NSNotification *)aNotification
{
    if([notification object] == textField)
    {
        textField.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:14];

    }
}
@end
于 2013-01-12T03:26:28.263 回答