我知道有一种绘制圆形的方法 - UIBezierPath(roundedRect, cornerRadius)
但是我想知道如果我自己剪辑角落,为什么我必须在绘制矩形之前添加剪辑?(我觉得在绘制之后剪切矩形更合理.我错过了什么概念?)
(1)工作
override func drawRect(rect: CGRect) {
var clipPath = UIBezierPath(roundedRect: rect, cornerRadius: 8.0)
path.addClip()
var rectPath = UIBezierPath(rect: rect)
UIColor.redColor().setFill()
rectPath.fill()
}
Run Code Online (Sandbox Code Playgroud)
(2)不工作
override func drawRect(rect: CGRect) {
var rectPath = UIBezierPath(rect: rect)
UIColor.redColor().setFill()
rectPath.fill()
var clipPath = UIBezierPath(roundedRect: rect, cornerRadius: 8.0)
path.addClip()
}
Run Code Online (Sandbox Code Playgroud) NSMutableArray *array = [NSMutableArray arrayWithObjects:@{@"name":@"Jenny",@"age":@23},@{@"name":@"Daisy",@"age":@27},nil];
Run Code Online (Sandbox Code Playgroud)
是否可以在数组的字典对象中按键删除对象?
例如.按年龄= 27删除对象
我有一个FirstViewController用TabBarController与NavigationController
(TabBarController> NavigationController>的UIViewController)
当按下UIButton时firstViewController,它会推到SecondViewController.
SecondViewController *vc2 = [self.storyboard instantiateViewControllerWithIdentifier:@"BVC"];
vc2.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:vc2 animated:YES];
Run Code Online (Sandbox Code Playgroud)
在SecondViewController有一个UILabel上有约束的右下角- (宽度相等,高度相等,TrailingSpaceToSuperView = 16,BottomSpaceToBottomLayoutGuide = 20)
结果在iphone4s(IOS7)上运行正常,但在iphone6(IOS8.1)上,UILabel它将首先出现在右下角加上"BottomBar height"大约1秒,然后将更新到正确的位置(BottomSpaceToBottomLayoutGuide = 20)
当我将pushViewController动画设置为NO时,UILabel会立即显示在正确的位置.
[self.navigationController pushViewController:vc2 animated:NO];
Run Code Online (Sandbox Code Playgroud)
有人遇到同样的问题吗?
我在keyWindow上添加了一个自定义视图.如何在自定义视图上显示UIAlertController?(现在警报只在我的自定义视图下弹出.)
let customView = CustomView()
UIApplication.sharedApplication().keyWindow!.addSubview(customView)
let alert = UIAlertController(title: NSLocalizedString("Error", comment: ""), message: "", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
presentViewController(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)