Install
openclaw skills install ios-view-generator从截图生成 Objective-C iOS 视图代码,支持懒加载模式和布局/数据分离。当用户需要:(1) 从截图生成 iOS UI 代码,(2) 生成 Objective-C 视图控制器或视图代码,(3) 创建遵循懒加载规范的 iOS 视图时触发此技能。
openclaw skills install ios-view-generator从截图生成规范的 Objective-C iOS 视图代码。
#pragma mark - Life Cycle // 生命周期
#pragma mark - UI // UI 创建
#pragma mark - Layout // 布局约束
#pragma mark - Data // 数据加载
#pragma mark - Event Response // 事件响应
#pragma mark - Lazy Load // 懒加载
setupUI 只负责 addSubView,setupConstraints 负责约束loadData 负责请求,refreshUI 负责绑定使用 image 工具分析用户提供的截图:
@interface MyViewController ()
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UILabel *titleLabel;
// ... 其他属性
@end
每个组件独立 getter:
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont boldSystemFontOfSize:18];
_titleLabel.textColor = [UIColor blackColor];
}
return _titleLabel;
}
- (void)setupUI {
[self.view addSubview:self.containerView];
[self.containerView addSubview:self.titleLabel];
}
- (void)setupConstraints {
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(20, 15, 20, 15));
}];
}
- (void)loadData {
// 网络请求或本地数据
}
- (void)refreshUI {
// 数据绑定到视图
self.titleLabel.text = self.dataModel.title;
}