I am developing a flutter plugin. The library that I use with Swift has a UITextField subclass. I cannot show this subclass on the screen. It only appears on the screen when I try it with the UITextField object. How can I show this object on the screen?
My Code
dnmTextField = DnmTextField(frame: rc)
dnmTextField?.autoresizingMask = .flexibleWidth
dnmTextField?.layer.borderWidth = 1.0
dnmTextField?.layer.borderColor = UIColor.black.cgColor
dnmTextField?.clipsToBounds = true
dnmTextField?.keyboardType = UIKeyboardType.numberPad
dnmTextField?.textAlignment = .center
dnmTextField?.backgroundColor = UIColor.black
dnmTextField?.placeholder = (args!["placeholder"] as! String)
let presentedViewController = viewController?.presentedViewController
let currentViewController: UIViewController? = (presentedViewController ?? viewController)
currentViewController?.view.addSubview(dnmTextField!)
Custom UITextField Subclass Reference
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@protocol DnmTextFieldDelegate <NSObject>
@optional
- (void) dnmTextFieldShouldBeginEditing:(NSInteger)typeId;
- (void) dnmTextFieldDidBeginEditing:(NSInteger)typeId;
- (void) dnmTextFieldDidEndEditing:(NSInteger)typeId;
- (void) dnmTextFieldEditingChange:(NSInteger)typeId;
- (void) dnmTextFieldDidClear:(NSInteger)typeId;
@end
@interface DnmTextField : UITextField
- (void)setSystemId:(NSString*)systemId;
- (void)setMaxLength:(NSUInteger)maxLength;
- (void)setType:(NSInteger)typeId;
- (BOOL)isEqualTo:(DnmTextField*)textField2;
- (void)clear;
- (BOOL)validateInput;
- (BOOL)isEmpty;
- (void)setSystemIdforGet:(NSString*)system_Id;
- (void)setTextAlignment:(NSTextAlignment)textAlignment;
- (NSInteger)getTextLength;
@property (nonatomic, weak) id<DnmTextFieldDelegate> dnmDelegate;
@property (nonatomic, assign) UIEdgeInsets edgeInsets;
@property (nonatomic, assign) NSDictionary *attrDictionary;
@property (nonatomic) NSUInteger maxLength;
@end
#endif