喜欢交朋友的加:微信号 dwjluck2013 1.UIButton+ImageTitleSpace.h #import <UIKit/UIKit.h> // 定义一个枚举(包含了四种类型的button) typedef NS_ENUM(NSUInteger, MKButtonEdgeInsetsStyle) { MKButtonEdgeInsetsStyleTop, // image在上,label在下 MKButtonEdgeInsetsStyleLeft, // image在左,labe…
通常.假设直接设置UIButton的图片和文字,默认的两者相对位置可能不是我们想要的,那么须要进行调整. 须要用到的函数例如以下: UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) top,left,bottom,right分别表示向各个方向的移动量 实例说明: UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50, 10…
Drawable drawable=getResources().getDrawable(R.drawable.xx); //获取图片 drawable.setBounds(left, top, right, bottom);  //设置图片参数 xx.setCompoundDrawablesRelativeWithIntrinsicBounds(null,all,null,null);  //设置到哪个控件的位置()     图片与文字距离 :属性android:drawablePadding…
UIButton 上默认是图片在左文字在右,而大多数情况这样默认的的显示形式都不能满足我们的需求,接下来我就这个问题分享一下我的心得. 默认情况下,不设置的效果,都是居中实现 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(50, 50, 150, 100); button.backgroundColor = [UIColor yellowColor]; [but…
经过分析,上述按钮效果实际上就是一个布局,一个最简单不过的垂直线性布局,上部分是一个ImageView,下部分是一个TextView,这个布局可点击.可设置监听. 我们首先要编写自己的ImageButton类,然后在主布局文件中为我们自定义的Button编写布局,最后在Activity中调用我们自定义ImageButton即可. 首先,我们编写一个MyImageButton类,继承自LinearLayout package com.billhoo.study; import android.co…
调整按钮的Edge属性,选择调整图片的Edge还是label的Edge,如图:…
UIImage *yuyinImage = [UIImage imageNamed:@"yuyin.png"]; [soundButton setImage:yuyinImage forState:UIControlStateNormal]; [soundButton setImage:yuyinImage forState:UIControlStateSelected]; [soundButton setImage:yuyinImage forState:UIControlState…
1.UIButton设置文字位置 有些时候我们想让UIButton的title居左对齐,我们设置 btn.textLabel.textAlignment = UITextAlignmentLeft 是没有作用的,我们需要设置 btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft; 但是问题又出来,此时文字会紧贴到做边框,我们可以设置 btn.contentEdgeInsets = UIEdgeInsetsMak…
之前写过一个博客是关于实现图片和文字左右或者上下布局的方法, 下面是博客的主要内容: 布局文件很简单,用来展示RadioButton的使用方法. 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width=&q…
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.c…