小编Ell*_*Yap的帖子

NSTextAttachment不会显示在CATextLayer上

我在UITextView上尝试了它的工作原理.但是当我使用CATextLayer时,图像留空了.

有人试过吗?

这是我在UIView drawRect中尝试过的代码

NSTextAttachment* attachment = [NSTextAttachment new];
attachment.image = [UIImage imageNamed:@"rainbow.png"];
NSAttributedString* imageString = [NSAttributedString attributedStringWithAttachment:attachment];
NSDictionary * attribute = @{NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:12]};
NSMutableAttributedString *speechString = [[NSMutableAttributedString alloc] initWithString: @"hi" attributes:attribute];
[speechString insertAttributedString:imageString atIndex:1];
[speechString appendAttributedString:imageString];
Run Code Online (Sandbox Code Playgroud)

然后添加到CATextLayer

CATextLayer * speechTextLayer = [CATextLayer layer];
[speechTextLayer setString:speechString];
[speechTextLayer setFrame:self.bounds];
[speechTextLayer setBackgroundColor:[UIColor whiteColor].CGColor];
[self.layer addSublayer:speechTextLayer];
Run Code Online (Sandbox Code Playgroud)

objective-c calayer nstextattachment ios

6
推荐指数
0
解决办法
270
查看次数

将 SKAction 添加到 Sprite 队列中,依次运行

我听触摸并将 SKAction 添加到精灵。如果现有操作尚未完成,我希望将操作添加到队列中,以便它一个接一个地执行。有没有类似的设计经验?

我确实使用了数组和块。如果有更简单的方法吗?

@interface GAPMyScene()
@property(strong,nonatomic)SKSpriteNode*ufo;
@property(strong,nonatomic)NSMutableArray*animationQueue;
@property(copy,nonatomic)void(^completeMove)();
@end

@implementation GAPMyScene

-(id)initWithSize:(CGSize)size {
    if (self = [super initWithSize:size]) {
        self.ufo = [SKSpriteNode spriteNodeWithImageNamed:@"Spaceship"];
        self.animationQueue = [[NSMutableArray alloc] init];
        __unsafe_unretained typeof(self) weakSelf = self;
        self.completeMove = ^(void){
            [weakSelf.ufo runAction:[SKAction sequence:[weakSelf.animationQueue copy]] completion:weakSelf.completeMove];
            NSLog(@"removeing %@", weakSelf.animationQueue);
            [weakSelf.animationQueue removeAllObjects];
        };
        [self addChild:self.ufo];
    }
    return self;
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    for (UITouch *touch in touches) {
        CGPoint location = [touch locationInNode:self];
        SKAction*moveAnimation = [SKAction moveTo:location duration:2];
        if (![self.ufo hasActions]) {
            [self.ufo …
Run Code Online (Sandbox Code Playgroud)

objective-c sprite-kit skaction

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

我在html纯文本中看到了音乐符号,但是有人知道它是如何发生的吗?

??

我看到了这两个符号,并复制了它。尝试做任何html实体或特殊字符..但我无法获得任何结果,我也无法在Google上找到任何信息,因为这不是可搜索的符号,任何人都可以解释这种平坦而尖锐的音乐符号在其中的存在标准?以及如何键入或生成它们以及任何同级兄弟?

?????

symbols special-characters

3
推荐指数
1
解决办法
5932
查看次数

如何在laravel上区分请求空字符串和null

在PHP我们可以做到

isset($_POST['name'])
Run Code Online (Sandbox Code Playgroud)

这样用户提交的空文本就可以被检测到.

但在laravel

$request->has('name')
Run Code Online (Sandbox Code Playgroud)

在空字符串上也返回null.

我需要找到一种方法来判断它是一个空字符串还是根本没有发布的字段

laravel-5

3
推荐指数
2
解决办法
3889
查看次数