uibutton

UIButton ------ UIEdgeInsets属性

纵饮孤独 提交于 2020-02-03 04:22:35
UIButton共有三种属性 1.contentEdgeInsets 2.titleEdgeInsets 3.imageEdgeInsets UIEdgeInsets 先来看看内部代码是怎样写的 typedef struct __attribute__ ( ( objc_boxable ) ) UIEdgeInsets { CGFloat top , left , bottom , right ; } UIEdgeInsets ; 原来是结构体,它的四个参数:top, left, bottom, right, 分别表示距离上边界,左边界,下边界,右边界的位移,默认值均为0。 contentEdgeInsets 我们都知道,UIButton按钮可以只设置一个UILabel或者一个UIImageView,还可以同时具有UILabel和UIImageView;如果给按钮设置contentEdgeInsets属性,就是按钮的内容整体(包含UILabel和UIImageView)进行偏移 按钮内容整体向右下分别移动10像素: button . contentEdgeInsets = UIEdgeInsetsMake ( 10 , 10 , - 10 , - 10 ) ; titleEdgeInsets & imageEdgeInsets 这两个属性的效果是相辅相成的

iPhone之表视图按钮事件

拟墨画扇 提交于 2020-01-29 14:32:56
表视图的列表按钮 SecondLevelViewControlle r.h---查看前边例子 接口实现: #import <Foundation/Foundation.h> #import "SecondLevelViewControlle r.h" @interface RowControlsController : SecondLevelViewControlle r { NSArray *list; } @property (nonatomic, retain) NSArray *list; - (IBAction)buttonTapped:(id)sender; @end 实现: #import "RowControlsController.h" @implementation RowControlsController @synthesize list; //表视图按钮的点击事件 - (IBAction)buttonTapped:(id)sender { UIButton *senderButton = (UIButton *)sender; UITableViewCell *buttonCell = (UITableViewCell *)[senderButton superview]; //获取表视图的一行id NSUInteger buttonRow = [

UIButton won't gray out

戏子无情 提交于 2020-01-29 03:24:48
问题 Isn't UIButton supposed to become grayish/grayer when enabled=NO ? I have a simple UIButton on a blackbackground (no custom images, no custom nothing, just dragged it with IB and changed size and title). And when I set it programatically to become disabled it stays white as hell! For now I'm using a small stupid workaround: hidden blackbg 0,5 alpha UIView on top of the button that becomes hidden=NO when I need to disable the button... but I would like to set the button properly... Any

iOS-调用网页聊天、拨打电话

这一生的挚爱 提交于 2020-01-28 03:26:57
@property (nonatomic,strong) UIButton *but; @property (nonatomic,strong) UIButton *but1; @property (strong, nonatomic) UIView *subView; //客服QQ -(void)qqAction { self.but = [UIButton buttonWithType:UIButtonTypeCustom]; self.but.frame = self.view.bounds; self.but.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400]; [self.but addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:self.but]; self.but1 = [UIButton buttonWithType:UIButtonTypeCustom]; self.but1.frame = self.view.bounds; self.but1.backgroundColor = [UIColor

Call html pages located different folder via UIbutton objective-c

半腔热情 提交于 2020-01-26 00:39:37
问题 I have one page with 4 buttons, it's UIViewController , and in my application I have 4 folder that inside of each folder I have one html file , I have another webViewController that I should load this html files inside of that webViewController , I mean when click on first button load first html , if click second load second html and .... would you please help me to implement this: here is my method : -(void)loadWebView{ NSURL *url = [NSURL fileURLWithPath:[ [ NSBundle mainBundle ]

UIButton Custom font issue

老子叫甜甜 提交于 2020-01-25 07:07:25
问题 I have added a custom font in to my application and i set that custom font for some of the buttons by sub classing the custom font,in xib custom font set perfectly but while execute in device the font auto adjust to upside in all the button. Here is my custom font sub class code. @interface ButtonWithBebasNeueFont : UIButton @end @implementation ButtonWithBebasNeueFont - (void)awakeFromNib { [super awakeFromNib]; self.titleLabel.font = [UIFont fontWithName:@"BebasNeue" size:self.titleLabel

uicollectionview 使用uibutton或者uiimageview实现旋转出现scale的问题

*爱你&永不变心* 提交于 2020-01-24 16:16:58
uicollectionview下单独使用uibutton然后setimage或者直接使用uiimageview然后一定角度旋转后发现size会变动 解决方案:添加uibutton到uicollectionvview然后添加uiimageview到uibutton上而后旋转没有问题 但是点击时候即便设置的uiimageview的相关可点击属性依然无法实现button的点击,解决途径:tapgesture判断 代码如下: self.subThemeGobackBtn = [UIButton buttonWithType:UIButtonTypeCustom]; self.subThemeGobackBtn.frame = CGRectMake(self.collectionView.bounds.size.width / 2 + 60.0f, positionY, 0.0f, 0.0f); [self.subThemeGobackBtn setBackgroundColor:[UIColor clearColor]]; // [self.subThemeGobackBtn addTarget:self action:@selector(gobackToPerviousScreen:) forControlEvents:UIControlEventTouchUpInside];

Cannot subclass UIButton: Must call a designated initializer of the superclass 'UIButton'

删除回忆录丶 提交于 2020-01-24 02:21:06
问题 Trying to subclass UIButton but the error Must call a designated initializer of the superclass 'UIButton' occurs. Researching several SO posts like this, this, this, or several others did not help as those solutions didn't work. How can we subclass UIButton in Swift and define a custom init function? import UIKit class KeyboardButton : UIButton { var letter = "" var viewController:CustomViewController? required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented"

UIButton style when added to navigationItem.titleView

喜欢而已 提交于 2020-01-23 02:03:33
问题 I need to add a button to the UINavigationItem titleView (actually to the center of the UINavigation Bar. I've used the following code to accomplish so: UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(0, 0, 70, 30); [btn setSelected:YES]; [btn setTitle:@"list" forState:UIControlStateNormal]; And I've go the following: I need to give the same style of the "Done" button (which is UIBarButtonItem ) to the button "list"? 回答1: You can use

Add a click event to some text in ios NSString

谁说胖子不能爱 提交于 2020-01-22 23:06:53
问题 I have the following code and want to make parts of my text be clickable and call another UIViewController (not a website). NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"testing it out @clickhere"]; NSInteger length = str.length; [str addAttribute:NSForegroundColorAttributeName value:[UIColor bestTextColor] range:NSMakeRange(0,length)]; The NSMutableAttributedString gets set to a UILabel like so: label.attributedText = str; Whats the best way to do this?