自定义视图窗口控件
2015-04-21 10:04
274 查看
#import <UIKit/UIKit.h>@interface LTView : UIView#warning 创建需要的属性@property (nonatomic, retain) UILabel *mLabel;@property (nonatomic ,retain) UITextField *mTextField;@end
#import "LTView.h"
@implementation LTView
#warning 第一步,重写初始化方法- (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { [self createMyView]; } return self;}#warning 第三步,创建视图- (void)createMyView{ //初始化我们定义的属性 self.mLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 70, 50)]; self.mLabel.backgroundColor = [UIColor greenColor]; [self addSubview:self.mLabel]; [_mLabel release]; self.mTextField = [[UITextField alloc]initWithFrame:CGRectMake(90, 10, 230, 50)]; self.mTextField.backgroundColor = [UIColor yellowColor]; [self addSubview:self.mTextField]; [_mTextField release];}#import "AppDelegate.h"@interface AppDelegate ()@end@implementation AppDelegate- (void)dealloc{ [_window release]; [super dealloc];}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; [_window release]; LTView *mView = [[LTView alloc]initWithFrame:CGRectMake(10, 100, 340, 70)]; mView.backgroundColor = [UIColor grayColor]; [self.window addSubview:mView]; [mView release]; return YES;}
#import "LTView.h"
@implementation LTView
#warning 第一步,重写初始化方法- (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { [self createMyView]; } return self;}#warning 第三步,创建视图- (void)createMyView{ //初始化我们定义的属性 self.mLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 70, 50)]; self.mLabel.backgroundColor = [UIColor greenColor]; [self addSubview:self.mLabel]; [_mLabel release]; self.mTextField = [[UITextField alloc]initWithFrame:CGRectMake(90, 10, 230, 50)]; self.mTextField.backgroundColor = [UIColor yellowColor]; [self addSubview:self.mTextField]; [_mTextField release];}#import "AppDelegate.h"@interface AppDelegate ()@end@implementation AppDelegate- (void)dealloc{ [_window release]; [super dealloc];}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; [_window release]; LTView *mView = [[LTView alloc]initWithFrame:CGRectMake(10, 100, 340, 70)]; mView.backgroundColor = [UIColor grayColor]; [self.window addSubview:mView]; [mView release]; return YES;}
相关文章推荐
- 简易密码输入自定义控件示例 含自定义事件 可在调用窗口事件视图中看到事件名
- VC++单文档分割窗口、在视图中添加控件,并响应该控件的事件
- Android 自定义视图容器控件拦截ontouch事件传递给其子控件
- 自定义控件(视图)28期笔记06:自定义控件之 自定义属性
- QT下自定义QQ聊天窗口tab控件
- Tabhost控件 —漩涡鸣人窗口视图容器
- MFC程序实现窗口分割,视图快捷插入控件和插入列表
- 自定义视图控件例:自定义正方形
- 自定义视图(组合控件)
- 如何自定义View视图控件案例开发(一)
- [IOS_UI控件]iPhone应用开发之一:窗口,视图,视图控制器和UIKit基础
- [转]ASP.NET1.1中关于验证控件和自定义弹出确认窗口的冲突问题
- WIN32窗口子类化----自定义Edit控件的右键菜单
- 通过小练习掌握MFC知识点之起步篇-父子窗口间传值、ListCtrl隔行变色、双缓冲技术解决控件闪烁、自定义消息等
- setMeasuredDimension(widthMeasureSpec, heightMeasureSpec)方法导致在视图中自定义ViewGroup一下的控件显示不出来
- 自定义view简单的视图控件,控制view的背景颜色
- CLR自定义.NET控件制作(3)——自定义视图控件
- Android--自定义视图控件(一)(Android Studio)
- 控件视图Android 自定义视图容器控件拦截ontouch事件传递给其子控件
- 自定义MFC中的选项卡窗口控件CCoolTabCtrl