如果需要相对自己的中心点,则需要用bound.origin来计算 UIView加外边框 reference CGFloat borderWidth = 2.0f; self.frame = CGRectInset...(self.frame, -borderWidth, -borderWidth); self.layer.borderColor = [UIColor yellowColor].CGColor; self.layer.borderWidth...= borderWidth; UIView切换动画 只要提供View的初识状态和结束状态,然后交给showAnimation来做即可 -(void)showAnimation { [self.view..., textField.frame.size.width, textField.frame.size.height); border.borderWidth = borderWidth; [...(void)viewWillAppear:(BOOL)animated { //不调用super方法 屏蔽自动滚动 //[super ...]; } 判断UITableViewCell是否可见
+Border&CornerRadius.m #import "UIView+Border&CornerRadius.h" @implementation UIView(border_cornerRadius...) /** * 设置边框宽度 * * @param borderWidth 可视化视图传入的值 */ @dynamic borderWidth; - (void)setBorderWidth...:(CGFloat)borderWidth { if (borderWidth < 0) return; self.layer.borderWidth = borderWidth.../** * 设置边框宽度 * * @param borderWidth 可视化视图传入的值 */ - (void)setBorderWidth:(CGFloat)borderWidth...{ if (borderWidth < 0) return; self.layer.borderWidth = borderWidth; } /** * 设置边框颜色
创建UIView的分类,使用IBInspectable+ IB_DESIGNABLE关键字: #import IB_DESIGNABLE @interface UIView...; @property(nonatomic,assign) IBInspectable UIColor *borderColor; @end #import "UIView+Inspectable.h...{ self.layer.borderWidth = borderWidth; } - (CGFloat)cornerRadius{ return self.layer.cornerRadius...; } - (CGFloat)borderWidth{ return self.layer.borderWidth; } - (UIColor *)borderColor{ return...动态显示设置效果 直接使用的话只有在运行时才能看到效果, 例如要实时显示一个UIBUtton圆角、描边效果,需要创建一个类继承UIButton #import #import "UIView
高级 创建UIView的分类,使用IBInspectable+ IB_DESIGNABLE关键字: #import IB_DESIGNABLE @interface...UIView (Inspectable) @property(nonatomic,assign) IBInspectable CGFloat cornerRadius; @property(nonatomic...; @end #import "UIView+Inspectable.h" @implementation UIView (Inspectable) -(void)setCornerRadius:...{ self.layer.borderWidth = borderWidth; } - (CGFloat)cornerRadius{ return self.layer.cornerRadius...; } - (CGFloat)borderWidth{ return self.layer.borderWidth; } - (UIColor *)borderColor{ return
只影响背景颜色不影响背景图和子图层,所以往往我们在设置圆角时还会开启view的masksToBounds(剪裁属性),当设置成YES时,图层里面所有东西都会被截取 边框 边框需要设置layer的两个属性,borderWidth...和borderColor,并且边框是沿着图层bounds绘制,同时包含图层的角 borderWidth边框的宽度,以点为单位,默认是0;borderColor边框的颜色,默认是黑色 阴影 阴影一般需要设置...*(^BorderWidth) (CGFloat width); typedef UIView *(^ShadowColor) (UIColor* color); typedef UIView...*(^ShadowOffset) (CGSize size); typedef UIView *(^ShadowRadius) (CGFloat radius); typedef UIView *...borderWidth; // 边框宽度 默认0 // 阴影 @property(nonatomic, strong, readonly)ShadowColor shadowColor;
(weak, nonatomic) IBOutlet UIView *rightView; @end @implementation ViewController - (void)viewDidLoad...图层边框 border CALayer另外两个非常有用的属性borderWidth和borderColor。 borderWidth是以点为单位定义边框粗细的浮点数,默认为0。...(weak, nonatomic) IBOutlet UIView *rightView; @property (weak, nonatomic) IBOutlet UIView *shadowView...= 5.f; self.rightView.layer.borderWidth = 5.f; // 不添加其他图层直接给 leftView 设置阴影试一试 self.leftView.layer.shadowOffset...CALayer蒙板图层不局限于静态图,也可以通过代码甚至是动画实时生成蒙板。 拉伸过滤 关于这些我看了原文,确实不懂,而且我也没碰到过,无从下手做笔记。
sectorView = [[ICSectorProgressView alloc] initWithFrame:self.appImageView.bounds]; _sectorView.borderWidth...YES;// 默认隐藏 } return _sectorView; } 与下载进度配合使用,定义进度属性 @interface ICSectorProgressView : UIView...@property(assign,nonatomic)CGFloat progress; @property (nonatomic, assign)CGFloat borderWidth; -(void...UIColor blackColor] set]; // 设置扇形的填充模式 [sectorPath fill]; } 2、数据下载完成后外围灰边框动画 画出默认的边框,并加载到uiview...CGColor; _borderLayer.path = [self maskPathWithDiameter:CGRectGetHeight(self.bounds) - self.borderWidth
圆角、描边 先来看看设置圆角、描边 extension UIView { @IBInspectable var cornerRadius: CGFloat { get {...newValue layer.masksToBounds = newValue > 0 } } @IBInspectable var borderWidth...: CGFloat { get { return layer.borderWidth } set { layer.borderWidth...} 添加完成就可以在 IB 中设置 view 的这些属性了 运行效果 利用 @IBDesignable 在 IB 中实时显示 @IBInspectable 的样式 创建一个新的 class 继承 UIView...,并且使用 @IBDesignable 声明 import UIKit @IBDesignable class IBDesignableView: UIView { } 在 IB 中,选择 view
* _headView; //日历的展示 UIView * _bodyViewL; UIView * _bodyViewM; UIView * _bodyViewR;... label.text=weekArray[i]; label.textAlignment = NSTextAlignmentCenter; label.layer.borderWidth...=[[UIColor grayColor] CGColor]; label.textColor = [UIColor whiteColor]; label.layer.borderWidth...UIControlStateNormal]; } //是否进行自定义标记 /** *if中的颜色比较 是为了让上月与下月的余日不产生... btn.layer.borderColor = [[UIColor grayColor]CGColor]; btn.layer.borderWidth
let view1 = UIView(frame: rect) view1.backgroundColor = UIColor.red view1.layer.cornerRadius...= 50 view1.layer.borderWidth = 2 view.addSubview(view1) ?...let view1 = UIView(frame: rect) view1.backgroundColor = UIColor.red view1.layer.cornerRadius...在当同时设置了backgroundColor|borderWidth,cornerRadius,contents,masksToBounds这四个属性时,导致了离屏渲染。...let view1 = UIView(frame: rect) view1.layer.cornerRadius = 50 view1.layer.contents =
CIFaceFeature *faceFeature in features){ } // 标出脸部 CGFloat faceWidth = faceFeature.bounds.size.width; UIView...* faceView = [[UIView alloc] initWithFrame:faceFeature.bounds]; faceView.layer.borderWidth = 1; faceView.layer.borderColor...redColor] CGColor]; [self.view addSubview:faceView]; // 标出左眼 if(faceFeature.hasLeftEyePosition) { UIView...0.15; [self.view addSubview:leftEyeView]; } // 标出右眼 if(faceFeature.hasRightEyePosition) { UIView...faceWidth*0.15; [self.view addSubview:leftEye]; } // 标出嘴部 if(faceFeature.hasMouthPosition) { UIView
Xcode中开发者账号登陆不上 ? 试了试其他的账号也是一样,在账号密码没有输入错误的情况下还是登陆不上。 解决办法:重启电脑就解决了。 2. Xcode9中往工程中拖入文件很容易报错 ?...4.修改UITextField 的placeholder字体不起效果 _numberTF.placeholder = @"请输入数量"; [_numberTF setValue:GrayTextColor...reverseObjectEnumerator]; BOOL haveHUD = NO; for (UIView *subview in subviewsEnum) { if ([...10.为UIView添加边框时的Bug 这个问题也不是难,就是隐藏性比较强,稍不注意,不认真分析,想当然的话就会被困住很久。 ?...whiteColor]; [self addSubview:self.whiteBgView]; [self.whiteBgView addBorderForColor:[UIColor redColor] borderWidth
UIView和CALayer都继承自NSObjet。 继承结构 UIView的继承结构为: UIResponder : NSObject。...1 2 3 4viewT.layer.cornerRadius = 10;//设置半径 viewT.layer.borderWidth = 10;//设置边框的宽度,当然可以不要 viewT.layer.borderColor...UIView侧重于对显示内容的管理,CALayer侧重于对内容的绘制。 UIView和CALayer是相互依赖的关系。...UIView依赖与CALayer提供的内容,CALayer依赖UIView提供的容器来显示绘制的内容。...UIView来自CALayer,高于CALayer,是CALayer的高层实现与封装。UIView的所有特性来源于CALayer支持。 参考: 图片引用
,而对动力引擎(dynamics engine)不可见;相反边界(boundary)对动力引擎可见,对用户不可见 随着square的下降,它似乎与barrier相互作用,但它实际上是与不可动的boundary...这个协议意味着动态不紧密耦合UIView; 确实有另一个UIKit类不是视图,但仍然采用这个协议:UICollectionViewLayoutAttributes。...UIView collidingView.backgroundColor = UIColor.yellow UIView.animate(withDuration: 0.3) { collidingView.backgroundColor...backgroundColor outline.layer.borderWidth = 1.0 self.view.addSubview(outline) }...allowRotation - 这是一个有趣的,不建模任何现实世界的物理属性。将此属性设置为“否”,无论发生何种旋转力,对象都不会旋转。 十、动态添加行为 下面,介绍如何动态添加和删除行为。
CGRectMake(50, 100, LBSCREEN_WIDTH-100, 30); [self.view addSubview:backimageView]; backView = [[UIView...backView.layer.cornerRadius = 5; backView.backgroundColor = [UIColor whiteColor]; backView.layer.borderWidth...login_btn.backgroundColor = [UIColor lightGrayColor]; login_btn.layer.cornerRadius = 5; login_btn.layer.borderWidth...forControlEvents:UIControlEventTouchUpInside]; pass_btn.layer.cornerRadius = 5; pass_btn.layer.borderWidth...= UITextBorderStyleRoundedRect; Pass_textfield.placeholder = @"密码"; //2秒后开始一个持续一分钟的动画 [UIView
对象,可以很方便地调整UIView的一些外观属性,例如可以给UIView设置阴影,圆角,边框等等... 2....CGColorRef //设置边框的颜色 _RedView.layer.borderColor = [UIColor whiteColor].CGColor; //设置边框的宽度 _RedView.layer.borderWidth...imageView.layer.shadowColor = [UIColor blueColor].CGColor;``` 3.2 设置图形边框 //设置边框宽度 _imageView.layer.borderWidth...UIView和CALayer都能够显示东西,该怎样选择? >对比CALayer,UIView多了一个事件处理的功能。...,用UIView或者CALayer都可以 我们平常开发中一般用UIView. ## 3.
每个控件都有自己的一个图层,这个空间的全部东西就是显示在这个图层上面的,控件本身没有显示东西的功能,仅仅有拥有了图层才干显示东西 图层的获取 CALayer *layer = self.testView.layer; 使用UIView...的图层为例 UIView本身仅仅有一个图层,主图层 self.testView.layer.borderWidth = 10;//设置边框大小 self.testView.layer.borderColor...并不能改变图片显示层的边角 self.imageView.layer.borderWidth = 10;//设置边框宽度大小 self.imageView.layer.borderColor = [
tableView.tableHeaderView = searchController.searchBar // now working 解决问题 1 searchController.searchBar.layer.borderWidth...your background color 解决问题 2 我发现 tableHeaderView 是可以被其他 view 有效填充的,不知道为什么 searchBar 就是放不进去,所以直接找个大小一样的 UIView...let containerView = UIView(frame: CGRectMake(0, 64, view.frame.width, 44)) containerView.backgroundColor
UIView是UIKit框架里面最基础的视图类。UIView类定义了一个矩形的区域,并管理该矩形区域内的所有屏幕显示。 控件 ?...image.png 1个UIWindow 或 UIView 1、设置背景色 import UIKit class ViewController:UIViewController { override...let view = UIView(frame:CGRect(x:40, y:80,width:240, height:240)) view.backgroundColor = UIColor.black...view) 修改不透明度 view.alpha = 0.3 是否隐藏 view.isHidden=true 是否交互 userInteractionEnabled 设置边框: view.layer.borderWidth...any resources that can be recreated. } } ---- 使用自定义视图:新建Swift File import UIKit class RoundView:UIView
self.tableView.tableHeaderView = ({ UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0...= 50.0; imageView.layer.borderColor = [UIColor whiteColor].CGColor; imageView.layer.borderWidth