我创建了UIView一个半透明的黑色背景,可以看到我的主应用程序视图.我在这里的目的是在一个UIView没有看到半透明黑色背景的地方创建一个切出的圆形状,除了圆形区域外,在整个图像上产生黑色遮罩的效果(这是为了突出显示)该区域的按钮).
我已经设法用来CAShapeLayer创建一个圆形面具,但这有相反的效果(即视图的其余部分是清晰的,并且圆圈内部是半透明的黑色.我想要的是除了圆圈保持半透明的黑色,然后内部清楚.这是我使用的代码,我将如何使其以相反的方式工作?我blackMask是半透明的黑色视图,我buttonCircle是圆圈我我希望保持清醒.
也许我需要以某种方式颠倒路径?
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGRect maskRect = buttonCircle.frame;
CGPathRef path = CGPathCreateWithEllipseInRect(maskRect, NULL);
maskLayer.path = path;
CGPathRelease(path);
blackMask.layer.mask = maskLayer;
Run Code Online (Sandbox Code Playgroud)
编辑:现在尝试这个,没有看到任何掩码与这一个:
UIView *circularMaskView = [[UIView alloc] initWithFrame:buttonCircle.frame];
circularMaskView.backgroundColor = [UIColor greenColor];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
CGPathRef path = CGPathCreateWithEllipseInRect(buttonCircle.frame, NULL);
maskLayer.path = path;
CGPathRelease(path);
circularMaskView.layer.mask = maskLayer;
[blackMask addSubview:circularMaskView];
Run Code Online (Sandbox Code Playgroud) 我已经在我的故事板中看到了一个视图,我现在决定通过静态表格单元格来显示它的数据.
我不能在UIViewController(Static table views are only valid when embedded in UITableViewController instances)中使用静态表视图.所以,我需要将我现有的转换UIViewController为UITableViewController某种方式.我已经更改了.h文件的父级,但是还没有完成.
还有另一种方法可以实现这一目标吗?我真的宁愿不必在故事板上创建一个新的VC并将所有东西都搬过来,这是一个很大的麻烦.
我通过对象和以下代码行存储Chipmunk Physics的cpShape对象:NSMutableDictionaryNSValue
NSValue *shapeValue = [[NSValue alloc] initWithBytes: shape objCType: @encode(cpShape)];
[staticBodiesInUse setObject: shapeValue forKey: name];
Run Code Online (Sandbox Code Playgroud)
我现在需要cpShape退出,将它与另一种形状进行比较.我怎样才能做到这一点?我看到一个getValue:方法,NSValue但它需要一个缓冲区,不太清楚如何处理它.
我有一个NSFetchedResultsController从核心数据结构,一个专辑列表中获取数据.它目前按艺术家排序,所以所有的A,B等等.我想添加一个索引,以便用户可以快速跳转到每个字母,我正在使用下面的代码来完成它.问题是节标题现在也是"A","B","C"等,这意味着我已经按字母顺序丢失了节目标题,每个艺术家都在其上("Adele","America" ","甲壳虫乐队,"等等)
我希望索引使用字母A到Z,但是节标题按字母顺序显示艺术家姓名.在索引中推送一个字母然后会跳转到第一个带有该字母的艺术家.我怎样才能实现这一点(索引中的字母字符,但部分标题的属性不同)?
编辑:如果我把我的sectionNameKeyPath给我的author领域,AZ指数是可见的,但如果我点击S上的字母不同步到的名称,例如,它需要我的艺术家与AL开头,或攻摹带我去AB.我不太清楚为什么会这样,也许这部分索引搞砸了?
这是我正在使用的代码:
在我的NSManagedObject子类中:
- (NSString *) firstLetter
{
[self willAccessValueForKey: @"firstLetter"];
NSString *firstLetter = [[[self author] substringToIndex: 1] uppercaseString];
[self didAccessValueForKey: @"firstLetter"];
return firstLetter;
}
Run Code Online (Sandbox Code Playgroud)
在我的View Controller中,要创建FRC:
NSFetchedResultsController *byAuthorFRC = [[NSFetchedResultsController alloc] initWithFetchRequest: _fetchRequest
managedObjectContext: [[CDManager sharedManager] managedObjectContext]
sectionNameKeyPath: @"firstLetter"
cacheName: nil];
Run Code Online (Sandbox Code Playgroud)
这是我的sectionIndexTitlesForTableView:方法:
- (NSArray *) sectionIndexTitlesForTableView: (UITableView *) tableView
{
return [self.fetchedResultsController sectionIndexTitles];
}
Run Code Online (Sandbox Code Playgroud) indexing core-data objective-c nsfetchedresultscontroller ios
我打电话一个UIAlertView与PlainTextView风格,而我试图找出我怎么能访问到任何文本视图中输入用户他们点击OK(确定).
我正在使用willDismissWithButtonIndex并且alertView似乎没有任何属性,如文本或任何东西.
我怎么能得到它?提前致谢!
我的应用程序不支持回到以前的曲目,我想知道我是否可以告诉锁屏音乐控件隐藏他们的倒带/上一个曲目按钮.我使用它MPNowPlayingInfoCenter将该信息传递给锁定屏幕.
很简单的问题,可以吗?例如,仅显示"播放/暂停"和"向前跳转"?
我有这个代码试图在一个循环中运行一组简单的图像.我在应用程序中的所有内容都是在我的View Controller的.h文件中声明的一个UIImageView:
@property (strong, nonatomic) IBOutlet UIImageView *imageDisplay;
Run Code Online (Sandbox Code Playgroud)
以下是我的.m文件的viewDidLoad方法:
NSMutableArray *imageView = [[NSMutableArray alloc] init];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim1.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim2.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim3.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim4.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim5.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim6.png"]]];
[imageView addObject:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"EyeAnim7.png"]]];
imageDisplay.animationImages = imageView;
imageDisplay.animationDuration = 0.25;
imageDisplay.animationRepeatCount = 50;
[imageDisplay startAnimating];
Run Code Online (Sandbox Code Playgroud)
代码似乎在"imageDisplay.animationImages"行上崩溃,就像我创建UIImageView,创建它的getter和setter,以及构建一样,直到我取消注释该行为止.如果我取消注释它,它会一直给我错误,直到我删除UIImageView并创建一个新的.
不太确定发生了什么,任何帮助表示赞赏!
我正在尝试按字母顺序重新排列单词.例如,番茄会成为amoott,或者堆栈会变得很难.
我已经找到了一些使用char数组在C中执行此操作的方法,但是我遇到了在NSString对象的范围内工作的问题.
在NSString对象本身中有更简单的方法吗?
简单的问题:WKInterfaceLabel如果文本太长而无法放入标签的框架内,是否有办法制作卷轴?类似于UITextView什么?
我试图在它们之后直接用分号找到""标记内的所有文本实例,并替换""标记内的文本.所以,例如:
"FirstKey" = "First value";
"SecondKey" = "Second value";
"ThirdKey" = "Third value";
Run Code Online (Sandbox Code Playgroud)
只会在等号后找到那些值,并且可以同时替换它们(使用单个字符串),如下所示:
"FirstKey" = "BLAH";
"SecondKey" = "BLAH";
"ThirdKey" = "BLAH";
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?我在Xcode 3中发现了一些引用正则表达式的东西,但这些功能似乎在Xcode 4中消失或隐藏.
ios ×8
objective-c ×7
apple-watch ×1
cashapelayer ×1
chipmunk ×1
cocoa-touch ×1
core-data ×1
indexing ×1
nsstring ×1
nsvalue ×1
regex ×1
replace ×1
sigabrt ×1
uialertview ×1
uiimageview ×1
uitableview ×1
uiview ×1
watchkit ×1
xcode ×1
xcode4 ×1