Coder Social home page Coder Social logo

mtanimatedlabel's Introduction

MTAnimatedLabel

This codebase implements MTAnimatedLabel, a UILabel subclass that supports animation like the iPhone lock screen.

License

Copyright (c) 2012 Michael Turner. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Automatic Reference Counting (ARC)

The source code in this repository uses Automatic Reference Counting.

Required Frameworks

MTAnimatedLabel requires the following frameworks:

CoreText
QuartzCore
UIKit
Foundation
CoreGraphics

Design

MTAnimatedLabel

A UILabel subclass that uses CATextLayer & CAGradientLayer to accomplish an iPhone lock screen like animation.

So how do I use it?

Just as you would use any other UILabel, either from a nib or in code.

/*Example*/
MTAnimatedLabel *label = [[MTAnimatedLabel alloc] initWithFrome:CGRectMake(0,0,100,35)];
label.text = @"slide to unlock";
[self.view addSubview:label];
[label startAnimating]; //begins animation

//call animate again to stop the animation
[label stopAnimating];

It's is also possible to change the gradient tint, animation duration, and gradient width.

Performance Considerations

MTAnimatedLabel uses a CATextLayer to mask a CAGradientLayer which requires off screen rendering. Due to this MTAnimatedLabel should only be used when animation is required.

TODO's

MTAnimatedLabel does not currently respect the following UILabel properties:

1. lineBreakMode
2. shadows on text are not currently working
3. baselineAdjustment
4. highlighting
5. autosizeTextToFit
6. numberOfLines

If you feel like jumping in on some of these please feel free!

mtanimatedlabel's People

Stargazers

Kevin Bradley avatar  avatar Fleeming avatar  avatar  avatar Thein Htike Aung avatar  avatar Monzy avatar Luckyfy avatar AbnerPei avatar Vijay Santhanam avatar EricWan avatar  avatar Nick Jaremek avatar  avatar Morgan Jiang avatar Ludovic Riviere avatar Neto Leal avatar Max Child avatar Michael avatar floprr avatar  avatar  avatar Babatunde Adeyemi avatar David Barker avatar Serge Maslyakov avatar Dustin Pfannenstiel avatar ibireme's bot avatar  avatar Joe Cerra avatar  avatar wallace avatar Nate Chiger avatar nat_a_cyborg avatar  avatar Jay O'Conor avatar Manivanna Raja avatar Chris D'Angelo avatar  avatar Zadorozhnyj Dmitrij avatar  avatar  avatar Noot avatar Issac Liu avatar Kris Haamer avatar Benjamin Davis avatar Michael Schade avatar Werner Ramaekers avatar Ali Sufyan avatar Kitsion avatar Brad Pillow avatar daqiang avatar  avatar  avatar Pavel Akhrameev avatar Pedro Vieira avatar Jaunce avatar Alexey Aleshkov avatar Ivan avatar youtoutou avatar Guysung Kim avatar Michael Turner avatar Nikita Korchagin avatar Alberto Jerez avatar Amit Vaghela avatar Viktor Malieichyk avatar David Sklenar avatar sunny avatar Mario avatar jtianling avatar  avatar Cornelius Schiffer avatar Mike Tran avatar Andrei avatar Anuj Seth avatar Max avatar Alejandro Martínez avatar jprothwell avatar Peter Thanakrit Weekhamchai avatar Sayan Chatterjee avatar Javi avatar Zaharia Andrei avatar Vladislav Alekseev avatar Jurica Cerovec avatar  avatar ming.z avatar mayulu avatar Sebas Barrios avatar Alexander Hramov avatar dmaha.ahn avatar Steve Wood avatar hiddenGithub avatar Romain Briche avatar Kyle Howells avatar  avatar  avatar  avatar SuperFancy avatar  avatar Wen-Hao Lue avatar

Watchers

Benjamin Davis avatar  avatar Nir Pengas avatar Brandon Emrich avatar mayulu avatar  avatar Javier Berlana avatar HoNooD avatar Ban avatar Paulo Khouri avatar Mike Tran avatar JACK ZHAO avatar nat_a_cyborg avatar Giovanni Dienstmann avatar Michael Turner avatar youtoutou avatar wdmchaft avatar  avatar  avatar

mtanimatedlabel's Issues

MTAnimatedLabel Crash

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]'

NSString ownership issue

In MTAnimatedLabel/MTAnimatedLabel.m line 132 (method -(UIFont *)font) does that toll-free bridge need to be cast as __bridge_transfer so ARC can manage the font name string you're copying from ctFont? It seems like this might run into a potential leak with that CoreFoundation string object never getting CFReleased.

BTW, thanks for this lib!!

compatibility with iOS 7

Are you planning on supporting iOS 7? In my Project it no longer compiles using the iOS 7 SDK.

Crash

I try to do the most basic example and it throws an error:

'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]'

I'm creating the object programmatically by:

MTAnimatedLabel *label = [[MTAnimatedLabel alloc] initWithFrame:CGRectMake(0,0,100,35)];
label.text = @"slide to unlock";
[self.view addSubview:label];
[label startAnimating];

The line it crashes on is:
gradientLayer.colors = @[(id)[textColor CGColor],(id)[self.tint CGColor], (id)[textColor CGColor]];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.