小编Jen*_*nny的帖子

UIBezierPath addClip和drawRect

我知道有一种绘制圆形的方法 - 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)

ios uibezierpath swift

9
推荐指数
1
解决办法
2820
查看次数

按键从NSMutableArray中删除对象

NSMutableArray *array = [NSMutableArray arrayWithObjects:@{@"name":@"Jenny",@"age":@23},@{@"name":@"Daisy",@"age":@27},nil];
Run Code Online (Sandbox Code Playgroud)

是否可以在数组的字典对象中按键删除对象?

例如.按年龄= 27删除对象

nsdictionary nsmutablearray ios

5
推荐指数
1
解决办法
2633
查看次数

pushViewController导致autoLayout问题使用hidesBottomBarWhenPushed(iphone6)

我有一个FirstViewControllerTabBarControllerNavigationController (TabBarController> NavigationController>的UIViewController)

当按下UIButtonfirstViewController,它会推到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)

有人遇到同样的问题吗?

pushviewcontroller ios autolayout

4
推荐指数
1
解决办法
1540
查看次数

UIAlertView显示在KeyWindow的子视图下

我在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)

uialertview ios

0
推荐指数
1
解决办法
181
查看次数