CJMViewCategory
视图接口扩展,包括 UIButton 的点击动画,UIView 的圆角设置,查找父视图等。
- UIButton (CJMViewAnimated):通过 touch 事件处理 button 的动画效果,不需要设置 UIButton 的事件。
- UIView (CJMViewRoundCorner):设置 view 的圆角,可以单独设置4个角的其中一项或几项。兼容 iOS11 以下的情况。
- UIView (CJMViewFind):通过子视图和父视图的类型找到父视图的实例。一般用于 UITableViewCell 的子视图反查 UITableViewDataSource 实例的情况。
示例
要运行示例项目,请先克隆仓库存档,然后从 Example 目录中运行 pod install
- UIButton (CJMViewAnimated)
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50, 200, 60, 40)];
[self.view addSubview:button];
UIImage *image = [UIImage imageNamed:@"left.jpeg"];
[button setImage:image forState:UIControlStateNormal];
button.cjmv_animated = [CJMViewAnimated new];
button.adjustsImageWhenHighlighted = NO;
- UIView (CJMViewRoundCorner)
CJMViewRoundCorner *corner = [[CJMViewRoundCorner alloc] init];
corner.maskedCorners = CJMViewMaskedCornersTop;
corner.maskedColor = [UIColor redColor];
corner.shadowRadius = 4;
corner.shadowOpacity = 1.0;
corner.shadowColor = [UIColor blueColor];
corner.shadowOffset = CGSizeMake(4, 4);
corner.borderWidth = 1.0;
corner.borderColor = [UIColor blackColor];
corner.radius = 20;
UIView *redView = [[UIView alloc] init];
redView.backgroundColor = [UIColor redColor];
[self.view addSubview:redView];
redView.cjmv_corner = corner;
redView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[redView.topAnchor constraintEqualToAnchor:self.view.topAnchor constant:50],
[redView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor constant:50],
[redView.widthAnchor constraintEqualToConstant:100],
[redView.heightAnchor constraintEqualToConstant:100],
]];
- UIView (CJMViewFind)
UITableView *tableView = [self findTableView];
要求
安装
CJMViewCategory 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile
pod 'CJMViewCategory'
作者
chenjm,[邮件地址隐藏]
许可证
CJMViewCategory遵从MIT许可证。更多信息,请参阅LICENSE文件。