GithubHelp home page GithubHelp logo

tianzhuchen / uibuttoncentertitleandimage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xiaolanlianhua/uibuttoncentertitleandimage

0.0 2.0 0.0 120 KB

UIButton+CenterImageAndTitle是UIButton的Category,专门用于修改UIButton的图片和文字位置,提供修改图片和文字位置的五种模式:1、图片和文字上下居中,图片在上,文字在下;2、图片和文字左右居中,文字在左,图片在右;3、图片和文字左右居中,图片在左,文字在右;4、文字居中,图片在左边;5、文字居中,图片在右边。

Objective-C 100.00%

uibuttoncentertitleandimage's Introduction

UIButtonCenterTitleAndImage

UIButton+CenterImageAndTitle是UIButton的Category,专门用于修改UIButton的图片和文字位置,提供修改图片和文字位置的五种模式:1、图片和文字上下居中,图片在上,文字在下;2、图片和文字左右居中,文字在左,图片在右;3、图片和文字左右居中,图片在左,文字在右;4、文字居中,图片在左边;5、文字居中,图片在右边。

Useage(用法)

1、导入#import "UIButton+CenterImageAndTitle.h" 2、直接调用方法 例如: UIButton button1 = [UIButton buttonWithType:UIButtonTypeCustom]; button1.frame = CGRectMake(60, 80+i60, kScreenWidth-60*2, 45); button1.tag = i; button1.backgroundColor = [UIColor yellowColor]; button1.titleLabel.font = [UIFont systemFontOfSize:15]; [button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [button1 setImage:[UIImage imageNamed:@"img_up"] forState:UIControlStateNormal]; [button1 setTitle:@"测试文本" forState:UIControlStateNormal]; [button1 addTarget:self action:@selector(testAction:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button1];

//上下居中,图片在上,文字在下 [button1 verticalCenterImageAndTitle:10.0f];

//左右居中,文字在左,图片在右 [button1 horizontalCenterTitleAndImage:50.0f];

//左右居中,图片在左,文字在右 [button1 horizontalCenterImageAndTitle:50.0f];

//文字居中,图片在左边 [button1 horizontalCenterTitleAndImageLeft:50.0f];

//文字居中,图片在右边 [button1 horizontalCenterTitleAndImageRight:50.0f];

Contact

License

UIButtonCenterTitleAndImage is maintained under the MIT license. The project itself is free for use in any and all projects. You can use UIButtonCenterTitleAndImage in any project, public or private, with or without attribution - though we prefer attribution! It helps us.

Unsure about your rights? Read more.

Individual credits for included code exist in the header files and documentation. We thank them for their contributions to the open source community.

uibuttoncentertitleandimage's People

Watchers

 avatar  avatar

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.