uibutton

UIButton frame does not increase with accessibility large font using Swift 5

前提是你 提交于 2020-04-13 19:56:27
问题 Large accessibility font size for UIButton title (.body or .headline) does not increase the frame of button but only increase the title text. It can clearly be seen in the screenshot below: Constraints are only top, leading and trailing, also in code I have added 2 lines: button.adjustsImageSizeForAccessibilityContentSizeCategory = true button.titleLabel?.numberOfLines = 0 The yellow background colour is of the button, thus identifying that only tappable area is the yellow area. I want to

How to add system icons for a UIButton programmatically?

狂风中的少年 提交于 2020-04-12 19:58:10
问题 It's easy to add a custom image or a background for a UIButton , but there seems to be no programmatic way to set one of the following default iOS icons for a UIButton , I know it can be applied to navigation bar buttons, I don't need that, I want to apply it to a simple UIButton , any hints? 回答1: For Swift 5 the syntax is: button.setImage(UIImage(systemName: "search"), for: .normal) You can also set the weight of the icon by adding SymbolConfiguration : let boldConfig = UIImage

How to add system icons for a UIButton programmatically?

半腔热情 提交于 2020-04-12 19:57:25
问题 It's easy to add a custom image or a background for a UIButton , but there seems to be no programmatic way to set one of the following default iOS icons for a UIButton , I know it can be applied to navigation bar buttons, I don't need that, I want to apply it to a simple UIButton , any hints? 回答1: For Swift 5 the syntax is: button.setImage(UIImage(systemName: "search"), for: .normal) You can also set the weight of the icon by adding SymbolConfiguration : let boldConfig = UIImage

iOS开发导航栏控件的作用

依然范特西╮ 提交于 2020-03-24 04:59:25
一,在iOS开发过程中针对一些导航栏上需要自定义视图的情况,有时候需要用系统自带的处理,有些时候需要自定义一些视图并把视图添加上去,这时候主要是它们的位置有些许差别,下面简单写下demo; 1,用导航栏系统自带的视图处理: 1 //1 中间的图片 2 UIImageView *imageBarView = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth / 2.f - 40.f, 20.f, 80, 30)]; 3 imageBarView.image = [UIImage imageNamed:@"中间视图名称"]; 4 self.navigationItem.titleView = imageBarView; 5 6 7 //2 导航栏右边的分类按钮 8 UIButton *buttonRightItem = [UIButton buttonWithType:UIButtonTypeCustom]; 9 buttonRightItem.frame = CGRectMake(0.f, 0.f, 50.f, 30.f); 10 [buttonRightItem setTitle:@"分类" forState:UIControlStateNormal]; 11 [buttonRightItem

Corner radius issue with UIButton

社会主义新天地 提交于 2020-03-21 11:32:12
问题 I want to add a corner radius to a UIButton. It is working fine but a problem occurs when I add image to it. It does not round its corners with images, the image is shown in full rectangle form. Please see the image, I have used the corner radius with red color and the output is as follow: Please help. 回答1: Did you try to use set the masksToBounds: property? Fore example: CALayer *layer = [myView layer]; [layer setMasksToBounds:YES]; [layer setCornerRadius:8.0]; That should do the trick. 回答2:

UIButton删除所有目标操作

纵然是瞬间 提交于 2020-03-09 21:30:10
我已经添加了多个target-action-forControlEvents:到UIButton。 我想一次性删除所有这些,而不释放任何东西。 然后我会设定新的目标。 这可能吗?我该怎么做呢? #1楼 @ progrmr在Swift 2中的回答: button.removeTarget(nil, action: nil, forControlEvents: .AllEvents) 和斯威夫特3: button.removeTarget(nil, action: nil, for: .allEvents) 注意:Swift没有 NULL ,所以我测试用 nil 替换它,它似乎工作正常。 #2楼 迅速: btnCancel.removeTarget(self, action: Selector(), forControlEvents: UIControlEvents.AllEvents) #3楼 调用 removeTarget:action:forControlEvents : ,为目标传递nil,为操作传递NULL,并使用设置所有位的控制掩码(UIControlEventAllEvents)。 Objective-C的 [someControl removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents]

SDWebImage源码解读(四)UIButton+WebCache

早过忘川 提交于 2020-03-07 18:53:45
UIButton+WebCache .h 文件 1.获取当前button的图片url。 - (nullable NSURL *)sd_currentImageURL; 2.根据不同的状态获取图片url。 - (nullable NSURL *)sd_imageURLForState:(UIControlState)state; 3.设置按钮不同状态的url,然后异步加载,并且缓存。 1 - (void)sd_setImageWithURL:(nullable NSURL *)url 2 forState:(UIControlState)state; 3 4 - (void)sd_setImageWithURL:(nullable NSURL *)url 5 forState:(UIControlState)state 6 placeholderImage:(nullable UIImage *)placeholder; 7 8 - (void)sd_setImageWithURL:(nullable NSURL *)url 9 forState:(UIControlState)state 10 placeholderImage:(nullable UIImage *)placeholder 11 options:(SDWebImageOptions)options; 12 13 -

AVplayer

跟風遠走 提交于 2020-03-07 06:00:36
#import "AppDelegate.h" 10 #import "FirstVC.h" 11 @implementation AppDelegate 12 13 - (void)dealloc 14 { 15 [_window release]; 16 [super dealloc]; 17 } 18 19 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 20 { 21 self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 22 // Override point for customization after application launch. 23 24 FirstVC *firstVC = [[FirstVC alloc] init]; 25 self.window.rootViewController = firstVC; 26 [firstVC release]; 27 28 self.window.backgroundColor = [UIColor

Add Selector to UIButton

我们两清 提交于 2020-03-02 03:31:07
问题 I have ViewController and then two different ViewControllers that extend that main ViewController , one for the iPhone and the other for the iPad. The iPad's ViewController instantiates a separate extended UIView and sets it as its own view. That view has some buttons, which I want to add its selector methods as some methods in the main ViewController . How can this be achieved? So here's a way to visualize this: Main ViewController | iPhone ViewController | iPad ViewController | Some UIView

iOS小技巧--UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框

ⅰ亾dé卋堺 提交于 2020-02-29 22:41:25
UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法 在iOS开发中,任何可见视图都是继承于UIView的。 继承体系中,大部分UIView的属性适用于其任何孩子。 而UIView的layer属性可以绘制UIView的各种效果。其实我们看到的View的动画实际上也是layer在绘制。 1、绘制圆角 cornerView.layer.cornerRadius = 20; cornerView.layer.masksToBounds = YES; masksToBounds防止子元素溢出父视图。 如果一个正方形要设置成圆形,代码为: cornerView.layer.cornerRadius = cornerView.frame.size.height/2; cornerView.layer.masksToBounds = YES; 2、绘制边框 borderView.layer.borderWidth = 1.0; borderView.layer.borderColor = [UIColor blackColor].CGColor; 注意此处使用的是 CGColor 而不是UIColor. 3、绘制阴影 shadowView.layer.shadowColor = [UIColor redColor].CGColor; shadowView