我主要使用Android模拟器进行开发。是否有一种快速方法(最好是键盘快捷键)在深色模式和浅色模式之间切换以测试深色/浅色主题?
我一直在尝试使用Quartz上下文显示文本,但无论我尝试过什么,我都没有运气得到文本显示(我能够显示各种其他Quartz对象).谁知道我可能做错了什么?
例:
-(void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSelectFont(context, "Arial", 24, kCGEncodingFontSpecific);
CGContextSetTextPosition(context,80,80);
CGContextShowText(context, "hello", 6);
//not even this works
CGContextShowTextAtPoint(context, 1,1, "hello", 6);
}
Run Code Online (Sandbox Code Playgroud) 奇怪的情况 - 来自苹果的例子有效,但在我稍微改变之后,文字不会显示.这段代码正确地绘制蓝色背景,但无论我做什么,都拒绝在其上绘制文本:
#import <UIKit/UIKit.h>
@interface CWnd : UIWindow @end
@implementation CWnd
- (void) drawRect : (CGRect) i_poRect
{
// This is working : windows is blue.
CGContextRef oContex = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor( oContex, 0, 0, 255, 1 );
CGContextFillRect( oContex, i_poRect );
// This is not working : not text is displayed.
CGContextSelectFont( oContex, "Monaco", 10, kCGEncodingFontSpecific );
CGContextSetRGBStrokeColor( oContex, 255, 0, 0, 1 );
CGContextSetRGBFillColor( oContex, 255, 0, 0, 1 );
CGContextSetTextDrawingMode( oContex, kCGTextFill );
CGContextSetTextPosition( oContex, 100, 100 …
Run Code Online (Sandbox Code Playgroud)