Question

I've created a custom UITextField with the following code:

textField.h

#import <UIKit/UIKit.h>

@interface textField : UITextField
@end

textField.m

#import "textField.h"

@implementation textField

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)drawRect:(CGRect)rect
{
    UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(0.5, 0.5, 261, 30) cornerRadius: 2];
    [UIColor.whiteColor setStroke];
    rectanglePath.lineWidth = 1;
    [rectanglePath stroke];

}

@end

But whenever I try: @property (nonatomic, strong) IBOutlet textField *textbox; I get an error asking if I meant "UITextBox" but if I use "UITextBox" the application crashes. Any idea as to how I can create custom properties?

Was it helpful?

Solution

It think your forgot to

#import "textField.h"

on the ViewController that you are using custom UITextField "textField"

Whoever downvote me, this is NOT a comment. See the screen shot.

Before #import "textField.h"

enter image description here

After #import "textField.h"

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top