为了在XXMainViewController中只能访问mainV而不能修改他的值,所以将子控件的view暴露在ViewController.h中,并添加read-only
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property(nonatomic, weak, readonly) UIView *mainV;
@property(nonatomic, weak, readonly) UIView *leftV;
@property(nonatomic, weak, readonly) UIView *rightV;
@end
运行效果图:

以上就是本文的全部内容,希望对大家学习iOS程序设计有所帮助。
注:相关教程知识阅读请移步到IOS开发频道。










