1、把手机屏幕分成上下。上下两部分都采用Linearlayout方式布局 <LinearLayout> <LinearLayout> 上半部分 </LinearyLayout> <LinearLayout> 下半部分 </LinearyLayout> </LinearLayout>2、下半部分LinearLayout高度固定,上半部分LinearyLayout设置layout_weight权重,占满剩余屏幕空间 <LinearLayout> <LinearLayout android:layout_height="wrap_content" android:llayout_weight="1"> //设置高度自适应,并且权重为1 </LinearyLayout> <LinearLayout android:layout_height="50px"> //下半部分设置高度固定 </LinearyLayout> </LinearLayout>3、下半部分LinearLayout中添加按钮,设置android:gravity右对齐。 <LinearLayout android:layout_height="50px" android:gravity="right"> //下半部分设置高度固定 <button andtoid:text="右下角按钮"/> </LinearyLayout>
Ⅱ IOS UIButton 文字不全,被压缩了。比如"P..y"
如果你没有使用AutoLayout
你需要改变button.frame = CGRectMake(xx, xx, 能够显示全文字的合适宽度, 比字体大2.0f的高度)
如果你使用了AutoLayout
你需要改变button的width Constraint至能够显示全文字的合适宽度.
Ⅲ Uibutton 标题文字位置怎么靠下方
双击button,会出现button_click事件的方法,在里面写form2 f=new form2();f.show();就OK了 如果对您有帮助,请记得为满意答案,!祝您生活愉快!vaela
Ⅳ ios中怎么设置uibutton上字体的大小
1.在IOS程序中设置UIButton的字体大小:
btn.frame = CGRectMake(x, y, width, height);
[btn setTitle: @"search" forState: UIControlStateNormal];
//设置按钮上的自体的大小
//[btn setFont: [UIFont systemFontSize: 14.0]]; //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法
//应该使用
btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[btn seBackgroundColor: [UIColor blueColor]];
//最后将按钮加入到指定视图superView
[superView addSubview: btn];
附:创建按钮的两种方法:
1、动态创建
btnfont = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btnfont setFrame:CGRectMake(100, 10, 120, 40)];
[btnfont addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
[btnfont setTitle:@"字体" forState:UIControlStateNormal];
btnfont.backgroundColor=[UIColor clearColor];
[self.view addSubview:btnfont];
2、在xib文件中已经创建好,通过tag获取按钮
UIButton *testButton= (UIButton*)[self.view viewWithTag:100];
[testButton addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
注册事件
-(void) test: (id) sender{
UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"ceshi" message:@"test11111" delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil] autorelease];
[av show];
}
2.设置UIButton的文字显示位置、字体的大小、字体的颜色
btn.frame = CGRectMake(x, y, width, height);
[btn setTitle: @"search" forState: UIControlStateNormal];
//设置按钮上的自体的大小
//[btn setFont: [UIFont systemFontSize: 14.0]]; //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法
//应该使用
btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[btn seBackgroundColor: [UIColor blueColor]];
//最后将按钮加入到指定视图superView
[superView addSubview: btn];
tvnamelabel=[[UIButton alloc]initWithFrame:CGRectMake(5,5,200,40)];
这样初始化的button,文字默认颜色是白色的,所有如果背景也是白色的话,是看不到文字的,
btn.contentHorizontalAlignment= ;//设置文字位置,现设为居左,默认的是居中
[btn setTitle:@“title”forState:UIControlStateNormal];// 添加文字
有些时候我们想让UIButton的title居左对齐,我们设置
btn.textLabel.textAlignment = UITextAlignmentLeft
是没有作用的,我们需要设置
btn.contentHorizontalAlignment = ;
但是问题又出来,此时文字会紧贴到做边框,我们可以设置
btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);
使文字距离做边框保持10个像素的距离。
设置UIButton上字体的颜色设置UIButton上字体的颜色,不是用:
[btn.titleLabel setTextColor:[UIColorblackColor]];
btn.titleLabel.textColor=[UIColor redColor];
而是用:
[btn setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
Ⅳ 如何调整UIButton里面的文字位置
关键在:
[m_iknowBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 10, 18, 0)];
其中
UIKIT_STATIC_INLINE UIEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom,CGFloat right) {
UIEdgeInsets insets = {top, left, bottom,
right};
return insets;
}
表示
这个表示title往右边偏移10像素,往上面偏移18像素。
第一个参数top如果为正表示往下偏移,第二个参数left如果为正表示往右偏远,第三个参数bottom如果为正表示往上偏移,第四个参数right如果为正表示往左偏移。
//右对齐
[login_bt setContentHorizontalAlignment:];
Ⅵ UIButton怎么添加下划线
1。如果你的Button不显示文字的话,直接设置其title就行了,然后设置其titleEdgeInsets.2.
如果显示文字的话,就直接添加一个UILabel就行了。label.text
=
@"_____________"
Ⅶ 如何设置UIButton中image与title在UIButton中居中显示
自定义一个TabBar,有四个Tab。每个tab均有一个图片与文字两部分组成,图片在上,文字在下,都相对tab左右居中,当然还需要点击。如果自己写一个View,里面放一个UIImageView、UILabel、UIButton(UIGestureRecognizer)。这都是很容易实现的。
但是突然一想,这几个元素,UIButton本来就就有,UIButton是能直接设置image与title的,那么把这两部分,移动一下位置应该就ok了。事实也是如此,但是过程却让我有点蛋疼。
设置UIButton的image与title均为设置他们的UIEdgeInsets。这点也没什么问题。但是它的UIEdgeInsets与我想的却不太一样,这个不一样如果写出来,就太麻烦了。就不写了。下面我就把正确的代码贴一下:
CGRect titleBounds = tab.titleLabel.bounds;
CGRect imgBounds = tab.imageView.bounds;
UIEdgeInsets imgInsets = UIEdgeInsetsZero;
UIEdgeInsets titleInsets = UIEdgeInsetsZero;
imgInsets.bottom = tab.frame.size.height / 2 - 4;
imgInsets.right = - titleBounds.size.width;
titleInsets.top = tab.frame.size.height / 2 - 4;
titleInsets.left = - imgBounds.size.width;
[tab setImageEdgeInsets:imgInsets];
[tab setTitleEdgeInsets:titleInsets];
注:tab就是一个UIbutton。
按以上的代码,是能实现这个效果的。
在尝试的过程中,我发现,UIButton的titlelabel与imageview都是有frame的,我视图设置他们的frame来实现居中的效果,结果发现,只要点击后,就会恢复原形(上下结构就变成左右结构了)。非常神奇的效果。不知道怎么回事儿。
Ⅷ 怎么修改 UIButton 的文字
// button.titleLabel.textAlignment = NSTextAlignmentLeft; 这句无效
button.contentHorizontalAlignment = ;
button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
这里使用
button.titleLabel.textAlignment = NSTextAlignmentLeft; 这行代码是没有效果的,这只是让标签中的文本左对齐,但
并没有改变标签在按钮中的对齐方式。
所以,我们首先要使用
button.contentHorizontalAlignment = ; 这行代码,把按钮的内容(控件)
的对齐方式修改为水平左对齐,但是这们会紧紧靠着左边,不好看,
所以我们还可以修改属性:
button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
这行代码可以让按钮的内容(控件)距离左边10个像素,这样就好看多了
Ⅸ ios 怎么动态改变 UIButton的title文字
ios中tabbar得title和navigationbar的title修改方法如下: self.tabBarItem.title = [NSString stringWithFormat:@""];//来设置tab的title self.title = @"";//设置navigationbar的title;