小编Rah*_*hul的帖子

使用CGContextShowTextAtPoint绘制文本但显示的文本是反转的,

  - (void)drawRect:(CGRect)rect {
    CGContextRef  context = UIGraphicsGetCurrentContext();


    CGContextSelectFont(context, "Arial", 24, kCGEncodingMacRoman);


    CGContextShowTextAtPoint(context, 80, 80, "I am Rahul", 7);





 }
Run Code Online (Sandbox Code Playgroud)

我正在尝试绘制文本,如上所示"我是Rahul",但是当我执行代码时,
文本显示,但它被反转,为什么它发生我不会得到!! 救命!!

iphone

8
推荐指数
2
解决办法
1万
查看次数

为什么没有调用drawRect方法?

#import <UIKit/UIKit.h>

@interface quartzViewController : UIViewController {
 IBOutlet UIView *myView;

}

@end


#import "quartzViewController.h"

@implementation quartzViewController


   -(void)drawRect:(CGRect)rect
   {   

 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);
   }

   - (void)viewDidLoad {
 [myView setNeedsDisplay];

 [super viewDidLoad];
   }
Run Code Online (Sandbox Code Playgroud)

我是否必须在笔尖中进行任何更改?

谢谢

iphone drawrect

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

标签 统计

iphone ×2

drawrect ×1