在iOS7中,不推荐使用CGContextSelectFont.弃用消息说我必须使用Core Text,但我不知道这段代码的确切等价物:
CGContextSelectFont(context, "Helvetica", kBarLabelSize, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 0, 0, 0, 1.0);
CGContextSetTextMatrix (context, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, 0.0));
CGContextShowTextAtPoint(context, barX, barY, [@"Some text" cStringUsingEncoding:NSUTF8StringEncoding], [barValue length]);
Run Code Online (Sandbox Code Playgroud)
我已经能够使用以下代码创建字体:
CFMutableAttributedStringRef attrStr = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
CTFontRef font = CTFontCreateWithName(CFSTR("Helvetica"), kBarLabelSize, NULL);
CFAttributedStringSetAttribute(attrStr, CFRangeMake(0, CFAttributedStringGetLength(attrStr)), kCTFontAttributeName, font);
Run Code Online (Sandbox Code Playgroud)
但是现在我可以用这种字体"绘制"文本到上下文中吗?
我有一个倒数计时器的应用程序.我已经使用一个标签更新了这个标签,这个标签是用定时器调用的函数更新的:
...
int timeCount = 300; // Time in seconds
...
NSTimer *myTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(actualizarTiempo:) userInfo:nil repeats:YES];
...
- (void)actualizaTiempo:(NSTimer *)timer {
timeCount -= 1;
if (timeCount <= 0) {
[timer invalidate];
} else {
[labelTime setText:[self formatTime:timeCount]];
}
}
Run Code Online (Sandbox Code Playgroud)
注意:formatTime是一个接收整数(秒数)并返回格式为mm:ss的NSString的函数
一切正常,也就是说,时间倒计时但问题是我在应用程序中有一个UITableView,如果我触摸桌面并拖动它(沿着单元格移动),计时器会停止,直到我从屏幕上松开手指...
这种行为是否正常?如果是,是否有任何方法可以避免它并在拖动表时使计时器工作?
在上一个版本的ox xCode(4.3)中,我看到了预定义模板(例如我们的主/明细模板),其中在.m文件中进行了接口声明.例如,在文件MyFile.h中有:
@interface MyFile
@property (nonatomic, retain) NSString *someProp;
@end
Run Code Online (Sandbox Code Playgroud)
在MyFile.m文件中有:
@implementation MyFile
@interface MyFile {
NSString * anotherProp;
}
- (id) init...
Run Code Online (Sandbox Code Playgroud)
为什么这样做?为什么没有将anotherProp声明为MyFile.h文件?
提前致谢
反正有没有检测到UITabBarController的tabbar会出现还是消失?我想与显示/隐藏标签栏的动画同时制作动画.
我没有找到任何方法来检测此事件.标签栏的"隐藏"属性不是一个选项,因为它会在动画结束后更改其值