OGeek|极客世界-中国程序员成长平台

标题: iphone - 如何将反射添加到 UILabel。 IOS [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 15:58
标题: iphone - 如何将反射添加到 UILabel。 IOS

(新手)问题在这里。搜索但在任何地方都找不到这个特定的答案.... 我想为 UILabel 添加反射(如果可能,还可以发光)。我看到了苹果的反射项目代码,但它适用于 UIImage 而不是标签。

只需将它添加到一个简单的时钟:

- (void)runTimer                    //Starts a timer which messages runClock every 0.5sec
{
    myTicker = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selectorselector(runClock)
                                              userInfo:nil repeats:YES];
}

- (void)runClock
{
    NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] 
                                  autorelease]; NSDate *date = [NSDate date]; 
    // This will produce a time that looks like "12:15:00 PM". 
    [formatter setTimeStyle:NSDateFormatterMediumStyle]; 

    [clockLabel setText:[formatter stringFromDate:date]];   
}



Best Answer-推荐答案


我写了一篇关于如何生成任何 UI 元素或元素组的反射的文章。 jar 头技术可以放入您的项目中,并且非常易于使用。源代码和文章可以在http://aptogo.co.uk/2011/08/no-fuss-reflections/找到

关于iphone - 如何将反射添加到 UILabel。 IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4951355/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4