Zoom UILabel & Re-render font at correct size

后端 未结 8 2414
情歌与酒
情歌与酒 2020-12-13 07:23

I have a multi-line UILabel that I want to enable zooming on.

I embedded it with a UIScrollView and set min zoom to .25 and max zoom to 4.

相关标签:
8条回答
  • 2020-12-13 08:22

    I tested JEzu's code in iOS 5.1 and 6 beta, it is working for a const text label, but cause other normal label require updating text content fail, i.e. the text is not changed...

    I subclass the UILabel as ZoomableLabel with JEzu's answer, and apply the class as the label's custom class and it works fine.

    0 讨论(0)
  • 2020-12-13 08:23

    I implemented Scrimmers's solution by subclassing UILabel as DetailedUILabel with overriding methods like this;

    import QuartzCore

    #import <QuartzCore/QuartzCore.h>
    

    override init method, initWithFrame whichever you want.

    - (id)init
    {
        self = [super init];
        if (self) {
            CATiledLayer *tiledLayer = (CATiledLayer *)self.layer;
            tiledLayer.levelsOfDetailBias = 4;
            tiledLayer.levelsOfDetail = 4;
            self.opaque = YES;
        }
        return self;
    }
    

    and layerClass, class method.

    + (Class)layerClass {
        return [CATiledLayer class];
    }
    
    0 讨论(0)
提交回复
热议问题