标签: uiview

可可:框架和边界之间有什么区别?

UIView及其子类都具有属性framebounds.有什么不同?

cocoa cocoa-touch uiview

567
推荐指数
9
解决办法
18万
查看次数

给UIView圆角

我的登录视图有一个子视图,其中有一个UIActivityView和一个UILabel说"登录...".此子视图的拐角不是圆角.我怎样才能让它们成圆形?

有没有办法在我的xib中做到这一点?

cocoa-touch uiview ios

562
推荐指数
11
解决办法
31万
查看次数

如何判断UIViewController的视图是否可见

我有一个标签栏应用程序,有很多视图.有没有办法知道某个特定UIViewController目前是否可以从内部看到UIViewController?(寻找房产)

uiviewcontroller uiview uiwindow ios

543
推荐指数
10
解决办法
23万
查看次数

如何使用Swift以编程方式添加约束

自上周以来我一直试图解决这个问题,而没有更进一步.好的,所以我需要在Swift中编程方式应用一些约束 来使用这段代码:UIView

var new_view:UIView! = UIView(frame: CGRectMake(0, 0, 100, 100));
new_view.backgroundColor = UIColor.redColor();
view.addSubview(new_view);

var constX:NSLayoutConstraint = NSLayoutConstraint(item: new_view, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterX, multiplier: 1, constant: 0);
self.view.addConstraint(constX);

var constY:NSLayoutConstraint = NSLayoutConstraint(item: new_view, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0);
self.view.addConstraint(constY);

var constW:NSLayoutConstraint = NSLayoutConstraint(item: new_view, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: new_view, attribute: NSLayoutAttribute.Width, multiplier: 1, constant: 0);
self.view.addConstraint(constW);

var constH:NSLayoutConstraint = NSLayoutConstraint(item: new_view, attribute: …
Run Code Online (Sandbox Code Playgroud)

uiview ios autolayout nslayoutconstraint swift

409
推荐指数
14
解决办法
38万
查看次数

如何只为UIView的左上角和右上角设置cornerRadius?

有没有办法cornerRadius只设置一个左上角和右上角UIView

我尝试了以下内容,但最终没有看到视图了.

UIView *view = [[UIView alloc] initWithFrame:frame];

CALayer *layer = [CALayer layer];
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRoundedRect:frame byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(3.0, 3.0)];
layer.shadowPath = shadowPath.CGPath;
view.layer.mask = layer;
Run Code Online (Sandbox Code Playgroud)

cocoa-touch cornerradius uiview ios

372
推荐指数
20
解决办法
21万
查看次数

UIView有圆角和投影?

我真的尝试了所有我能做到的但是没有一个能用于定制UIView......我只是想要一个带圆角的白色空白视图和一个浅色阴影(没有光照效果).我可以一个接一个地做这些,但通常clipToBounds/ maskToBounds冲突发生.

iphone cocoa-touch rounded-corners uiview ios

367
推荐指数
14
解决办法
25万
查看次数

UIView框架,边界和中心

我想知道如何以正确的方式使用这些属性.

据我所知,frame可以从我正在创建的视图的容器中使用.它设置相对于容器视图的视图位置.它还设置该视图的大小.

center可以从我正在创建的视图的容器中使用.此属性更改视图相对于其容器的位置.

最后,bounds是相对于视图本身.它会更改视图的可绘制区域.

你能给约之间的关系更多信息framebounds?那些clipsToBoundsmasksToBounds属性呢?

objective-c frame uiview bounds ios

315
推荐指数
4
解决办法
21万
查看次数

以编程方式创建具有颜色渐变的UIView

我正在尝试在运行时生成具有渐变颜色背景(纯色到透明)的视图.有没有办法做到这一点?

uiview uicolor ios

282
推荐指数
13
解决办法
21万
查看次数

如何向UIView添加触摸事件?

如何向UIView添加触摸事件?
我尝试:

UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, nextY)] autorelease];
[headerView addTarget:self action:@selector(myEvent:) forControlEvents:UIControlEventTouchDown];
// ERROR MESSAGE: UIView may not respond to '-addTarget:action:forControlEvents:'
Run Code Online (Sandbox Code Playgroud)

我不想创建子类和覆盖

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
Run Code Online (Sandbox Code Playgroud)

events objective-c touch uiview ios

272
推荐指数
9
解决办法
32万
查看次数

如何设置iPhone UIView z索引?

我想将一个视图移到另一个视图之上,我怎么知道视图的z索引,以及如何移动到顶部?

position z-index uiview ios

246
推荐指数
7
解决办法
20万
查看次数