当前位置: 代码迷 >> 综合 >> iOS-工具方法-UIView
  详细解决方案

iOS-工具方法-UIView

热度:76   发布时间:2023-12-18 12:08:38.0

所有继承自UIView的控件都可以调用该方法添加边框

UIView添加边框

//view添加边框
//参数说明,view->控件、borderWidth->边框宽度、borderColor->边框颜色、cornerradius->圆角、masksToBounds ->视图的图层上的子图层,如果超出父图层的部分就截取掉.
+ (void)view:(UIView *)view borderWidth:(CGFloat)width borderColor:(UIColor *)color cornerradius:(CGFloat)cornerradius masksToBounds:(BOOL)masksToBounds
{view.layer.borderWidth=width;if (color==nil) {color=[UIColor whiteColor];}view.layer.borderColor=color.CGColor;if (masksToBounds==YES) {view.layer.masksToBounds=masksToBounds;}view.layer.cornerRadius=cornerradius;
}

UIImage执行360°旋转动画

//360旋转动画 
+ (void)startAnimation:(UIImageView *)parabolaImageV duration:(CGFloat)duration
{CABasicAnimation* rotationAnimation;rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];rotationAnimation.duration =duration;rotationAnimation.cumulative = YES;rotationAnimation.repeatCount =100;[parabolaImageV.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];}