Giter Site home page Giter Site logo

iqlabelview's Introduction

IQLabelView

IQLabelView is used to add text overlay and resize and rotate it with single finger.

IQLabelView screenshot IQLabelView screenshot

How to install it?

CocoaPods is the easiest way to install IQLabelView. Run pod search IQLabelView to search for the latest version. Then, copy and paste the pod line to your Podfile. Your podfile should look like:

platform :ios, '7.0'
pod 'IQLabelView', '~> X.Y.Z'

Finally, install it by running pod install.

If you don't use CocoaPods, just import IQLabelView/ folder with all the .m, .h, and .bundle files to your project.

How to use it?

IQLabelView Class

@interface IQLabelView : UIView 

/**
 * Text color.
 *
 * Default: white color.
 */
@property (nonatomic, strong) UIColor *textColor;

/**
 * Border stroke color.
 *
 * Default: red color.
 */
@property (nonatomic, strong) UIColor *borderColor;

/**
 * Name of text field font.
 * 
 * Default: current system font
 */
@property (nonatomic, copy) NSString *fontName;

/**
 * Size of text field font.
 */
@property (nonatomic, assign) CGFloat fontSize;

/**
 * Image for close button.
 *
 * Default: sticker_close.png from IQLabelView.bundle.
 */
@property (nonatomic, strong) UIImage *closeImage;

/**
 * Image for rotation button.
 *
 * Default: sticker_resize.png from IQLabelView.bundle.
 */
@property (nonatomic, strong) UIImage *rotateImage;

/**
 * Placeholder.
 *
 * Default: nil
 */
@property (nonatomic, copy) NSAttributedString *attributedPlaceholder;

/*
 * Base delegate protocols.
 */
@property (nonatomic, weak) id <IQLabelViewDelegate> delegate;

/**
 *  Shows content shadow.
 *
 *  Default: YES.
 */
@property (nonatomic) BOOL showsContentShadow;

/**
 *  Shows close button.
 *
 *  Default: YES.
 */
@property (nonatomic, getter=isEnableClose) BOOL enableClose;

/**
 *  Shows rotate/resize butoon.
 *
 *  Default: YES.
 */
@property (nonatomic, getter=isEnableRotate) BOOL enableRotate;

/**
 *  Resticts movements in superview bounds.
 *
 *  Default: NO.
 */
@property (nonatomic, getter=isEnableMoveRestriction) BOOL enableMoveRestriction;

/**
 *  Hides border and control buttons.
 */
- (void)hideEditingHandles;

/**
 *  Shows border and control buttons.
 */
- (void)showEditingHandles;

/** Sets the text alpha.
 *
 * @param alpha     A value of text transparency.
 */
- (void)setTextAlpha:(CGFloat)alpha;

/** Returns text alpha.
 *
 * @return  A value of text transparency.
 */
- (CGFloat)textAlpha;

@end

IQLabelViewDelegate Protocol

@protocol IQLabelViewDelegate <NSObject>

@optional

/**
 *  Occurs when a touch gesture event occurs on close button.
 *
 *  @param label    A label object informing the delegate about action.
 */
- (void)labelViewDidClose:(IQLabelView *)label;

/**
 *  Occurs when border and control buttons was shown.
 *
 *  @param label    A label object informing the delegate about showing.
 */
- (void)labelViewDidShowEditingHandles:(IQLabelView *)label;

/**
 *  Occurs when border and control buttons was hidden.
 *
 *  @param label    A label object informing the delegate about hiding.
 */
- (void)labelViewDidHideEditingHandles:(IQLabelView *)label;

/**
 *  Occurs when label become first responder.
 *
 *  @param label    A label object informing the delegate about action.
 */
- (void)labelViewDidStartEditing:(IQLabelView *)label;

/**
 *  Occurs when label starts move or rotate.
 *
 *  @param label    A label object informing the delegate about action.
 */
- (void)labelViewDidBeginEditing:(IQLabelView *)label;

/**
 *  Occurs when label continues move or rotate.
 *
 *  @param label    A label object informing the delegate about action.
 */
- (void)labelViewDidChangeEditing:(IQLabelView *)label;

/**
 *  Occurs when label ends move or rotate.
 *
 *  @param label    A label object informing the delegate about action.
 */
- (void)labelViewDidEndEditing:(IQLabelView *)label;

@end

Example

- (void)viewDidLoad
{
    [super viewDidLoad];
    
	CGRect labelFrame = CGRectMake(100, 100, 60, 50);
    
    IQLabelView *labelView = [[IQLabelView alloc] initWithFrame:labelFrame];
    [labelView setDelegate:self];
    [labelView setShowsContentShadow:NO];
    [labelView setFontName:@"Baskerville-BoldItalic"];
    [labelView setFontSize:21.0];
    [labelView setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Placeholder", nil) attributes:@{ NSForegroundColorAttributeName : [UIColor redColor] }]];
    
    [self.view addSubview:labelView];
}

Reference

Inspired by

License

The MIT License (MIT) Copyright (c) 2014 Alexander Romanchev

iqlabelview's People

Contributors

kcandr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iqlabelview's Issues

Multiple Lines for label

Hi @kcandr , your controller is really nice. I was wondering how I could add multiple line support while editing long text.
Thanks

Break down with multiple labels

@tormorOoO hello IQLabel is really cool. but it has a bug. For example ,if you create two labels,when you create the second one,it become the first responder,then you delete the second one and directly click on the first one(not click on the view and then click on the first one),it will break down at the line "[_textView resignFirstResponder]; it will helpful if you fix it."
Apparently you are using an older version. I do not like to say it, but I could not reproduce this bug. Try the latest version and let me know if this happens again.

Label redisplay/editing

What's the correct way to persist this for redisplay? e.g. save the label to allow it to be edited. Thanks.

Multi-lines and Paragraph support

Hi @kcandr , your controller is really nice.
I saw you said you should update this for multi-lines and paragraph support soon.

The solution is to use UITextView instead of UITextField?

When can we get the updated IQLabelView that supports multiple lines?
Thanks

Unrecognized selector sent to instance

I keep getting unrecognized selector sent to instance, and I can't figure out why. Every time I try to resize the IQLabelView, I get the error. Is the control bugged or am I doing something completely wrong?

var aLabel = UITextField(frame: CGRectMake(0, 0, 50, 50))
        aLabel.clipsToBounds = true
        aLabel.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin
        aLabel.text = "jalla"  //caption.text
        aLabel.textColor = UIColor.whiteColor()
        aLabel.sizeToFit()

        var bigCaption = IQLabelView(frame: CGRectMake(100, 100, 60, 50))
        bigCaption.autoresizingMask = UIViewAutoresizing.FlexibleHeight|UIViewAutoresizing.FlexibleWidth
        bigCaption.delegate = self
        bigCaption.showContentShadow = false
        bigCaption.setTextField(aLabel)
        bigCaption.fontName = "Baskerville-BoldItalic"
        bigCaption.fontSize = 21.0
        bigCaption.sizeToFit()
        self.view.addSubview(bigCaption)
        bigCaption.becomeFirstResponder()

        currentlyEditingLabel = bigCaption

//Biglabel functions

func touchOutside(touchGesture: UITapGestureRecognizer){
    println("touch outside")
}
func labelViewDidClose(label: IQLabelView!) {
    println("label close")
}
func labelViewDidBeginEditing(label: IQLabelView!) {
    println("didbeginediting")
}
func labelViewDidStartEditing(label: IQLabelView!) {
    currentlyEditingLabel = label;

}
func labelViewDidShowEditingHandles(label: IQLabelView!) {
    currentlyEditingLabel = label
}
func labelViewDidHideEditingHandles(label: IQLabelView!) {
    currentlyEditingLabel = nil
}

Full error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OS_dispatch_semaphore copyWithZone:]: unrecognized selector sent to instance 0x14fc3c30'

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.