IOS应用/游戏 项目封装之:UILabel 应该如何拓展?

如果是在IOS的应用方面,很多时候,是不需要我们去做一些封装的和添加一些比较好看,比较好看的UILabel显示。

游戏方面,就避免不了需要提高IOS完全没有的显示风格,这就需要提供炫的风格了。

但是,应用谁说的准就不用呢?

在发展到今天,开源的项目提供给我们很多的方便,在UILabel上面,就有开源的封装类。

这个其实类似于上一节的,IOS 应用/游戏项目应该如何灵活封装 控件显示样式与项目颜色的公用    http://blog.csdn.net/zhbitxhd/article/details/24296067

实际上,这个开源的项目就是为了完成同样的事情。所以,我们不需要再造车轮

这里提供链接以供使用,并且,我们的项目也在使用。

THLabel   


https://github.com/MuscleRumble/THLabel


文章中,有详细的解释如何使用。这里我就不多说了。

Installation

Add CoreText.framework to your Link Binary with Libraries list.

And drag these files into your project:

  • THLabel.h
  • THLabel.m

You can create THLabels programmatically, or create them in Interface Builder by dragging an ordinary UILabel into your view and setting its Custom Class to THLabel.

Properties

    @property (nonatomic, assign) CGFloat shadowBlur;

Additionally to UILabel's shadowColor and shadowOffset, you can set a shadow blur to soften the shadow.

    @property (nonatomic, assign) CGFloat innerShadowBlur;
    @property (nonatomic, assign) CGSize innerShadowOffset;
    @property (nonatomic, strong) UIColor *innerShadowColor;

The inner shadow has similar properties as UILabel's shadow, once again additionally with a shadow blur. If an inner shadow and a stroke are overlapping, it will appear beneath the stroke.

    @property (nonatomic, assign) CGFloat strokeSize;
    @property (nonatomic, strong) UIColor *strokeColor;
    @property (nonatomic, assign) THLabelStrokePosition strokePosition;

You can set an outer, centered or inner stroke by setting the strokePosition property. Default value isTHLabelStrokePositionOutside. Other options are THLabelStrokePositionCenter andTHLabelStrokePositionInside.

    @property (nonatomic, strong) UIColor *gradientStartColor;
    @property (nonatomic, strong) UIColor *gradientEndColor;
    @property (nonatomic, copy) NSArray *gradientColors;

The gradient can consist of multiple colors, which have to be saved as UIColor objects in the gradientColorsarray. For more convenience, gradientStartColor and gradientEndColor will fill up the array accordingly.

    @property (nonatomic, assign) CGPoint gradientStartPoint;
    @property (nonatomic, assign) CGPoint gradientEndPoint;

The starting and ending points of the gradient are in the range 0 to 1, where (0, 0) is the top-left and (1, 1) the bottom-right of the text. The default value for gradientStartPoint is (0.5, 0.2) and for gradientEndPoint it is (0.5, 0.8).

    @property (nonatomic, assign) THLabelFadeTruncatingMode fadeTruncatingMode;

You can fade in/out your label by setting the fadeTruncatingMode property. Default value isTHLabelFadeTruncatingModeNone. The options are THLabelFadeTruncatingModeTail,THLabelFadeTruncatingModeHead and THLabelFadeTruncatingModeHeadAndTail.

    @property (nonatomic, assign) UIEdgeInsets textInsets;

Effects like stroke and shadow can't be drawn outside of the bounds of the label view. For labels that are not center-aligned, you may need to set text insets to move a bit away from the edge.





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值