我的登录视图有一个子视图,其中有一个UIActivityView和一个UILabel说"登录...".此子视图的拐角不是圆角.我怎样才能让它们成圆形?
有没有办法在我的xib中做到这一点?
我有一个标签栏应用程序,有很多视图.有没有办法知道某个特定UIViewController目前是否可以从内部看到UIViewController?(寻找房产)
自上周以来我一直试图解决这个问题,而没有更进一步.好的,所以我需要在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) 有没有办法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) 我真的尝试了所有我能做到的但是没有一个能用于定制UIView......我只是想要一个带圆角的白色空白视图和一个浅色阴影(没有光照效果).我可以一个接一个地做这些,但通常clipToBounds/ maskToBounds冲突发生.
我想知道如何以正确的方式使用这些属性.
据我所知,frame可以从我正在创建的视图的容器中使用.它设置相对于容器视图的视图位置.它还设置该视图的大小.
也center可以从我正在创建的视图的容器中使用.此属性更改视图相对于其容器的位置.
最后,bounds是相对于视图本身.它会更改视图的可绘制区域.
你能给约之间的关系更多信息frame和bounds?那些clipsToBounds和masksToBounds属性呢?
我正在尝试在运行时生成具有渐变颜色背景(纯色到透明)的视图.有没有办法做到这一点?
如何向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) 我想将一个视图移到另一个视图之上,我怎么知道视图的z索引,以及如何移动到顶部?
uiview ×10
ios ×9
cocoa-touch ×4
objective-c ×2
autolayout ×1
bounds ×1
cocoa ×1
cornerradius ×1
events ×1
frame ×1
iphone ×1
position ×1
swift ×1
touch ×1
uicolor ×1
uiwindow ×1
z-index ×1