uikit

iOS UIFont caching?

孤人 提交于 2020-01-12 13:51:21
问题 I am trying to figure out if I should cache [UIFont fontWithName:@"myfont" size:24]. I am reusing this font in many places. I am wondering if iOS is already caching this for me because font caching is very common at OS level. Can someone comment on this? Thanks. 回答1: Last time I checked, system fonts were cached (i.e. calling [UIFont systemFontOfSize:foo] twice returned you the same object). I'm not sure how often the cache flushes, but it would seem very silly to not cache fonts, since they

iOS UIFont caching?

六月ゝ 毕业季﹏ 提交于 2020-01-12 13:50:14
问题 I am trying to figure out if I should cache [UIFont fontWithName:@"myfont" size:24]. I am reusing this font in many places. I am wondering if iOS is already caching this for me because font caching is very common at OS level. Can someone comment on this? Thanks. 回答1: Last time I checked, system fonts were cached (i.e. calling [UIFont systemFontOfSize:foo] twice returned you the same object). I'm not sure how often the cache flushes, but it would seem very silly to not cache fonts, since they

draw a line in UIImageView problem

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-12 11:11:56
问题 In my application i can draw a line in a UIImageView by the code below,and i want redraw the line even longer when i call the function,however,the output come out is not as expected,it will just draw a new line and remove the old one,the length is remain the same jus the y position different,i dont know which line of my code is wrong or i havent understand the CGContext class in correct way,please help i have scratch my head all the days and cannot find out the problem - (void) drawLine {

draw a line in UIImageView problem

谁说我不能喝 提交于 2020-01-12 11:11:10
问题 In my application i can draw a line in a UIImageView by the code below,and i want redraw the line even longer when i call the function,however,the output come out is not as expected,it will just draw a new line and remove the old one,the length is remain the same jus the y position different,i dont know which line of my code is wrong or i havent understand the CGContext class in correct way,please help i have scratch my head all the days and cannot find out the problem - (void) drawLine {

UIKit: UIScrollView automatically scrolling when a subview increases its width past the edge of the screen

大城市里の小女人 提交于 2020-01-12 06:58:08
问题 In the context of the iPhone: I have a UIScrollView containing a UIImage . When the user taps the screen inside the UIImage , a UITextField is added where the user touched. The user can edit this UITextField , and the text field will automatically resize itself based on whether text was added or deleted. When the a UITextField being edited increases its width, the scrollview automatically scrolls to show the increased width. The problem comes in because the automatic scrolling of the

Swift 3.0 Syntax change for UIUserNotificationSettings

走远了吗. 提交于 2020-01-12 06:49:30
问题 I am using swift 3.0 and am trying to add badge numbers to my app. I believe the correct way to do this is similar to what is below. application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil )) application.applicationIconBadgeNumber = 5 However, I get an error for using '|' in UIUserNotificationSettings block and will also receive the error "Argument labels

CGContext rotation

北城余情 提交于 2020-01-12 03:56:09
问题 I have a 100x100 pixel image that I want to draw at various angles rotated around the center of the image. The following code works, but rotates around the original origo of the coordinate system (upper left hand corner) and not the translated location. Thus the image is not rotated around itself but around the upper left corner of the screen. The following code was run in a custom view in a blank application with nothing else but this. - (void)drawRect:(CGRect)rect { CGContextRef context =

UICollectionView drag finger over cells to select them

◇◆丶佛笑我妖孽 提交于 2020-01-11 20:00:54
问题 Using UICollectionView , is it possible to select multiple cells by dragging your finger over a few of them? E.g., if you drag your finger over a row of 6, and down into the next row, it would select all of them. Tried something simple: UISwipeGestureRecognizer *swipeGuesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)]; [self.collectionView addGestureRecognizer:swipeGuesture]; But that seemed to only call the method on the first cell that was

How to recreate the UITabBarItem image filter?

十年热恋 提交于 2020-01-11 19:57:22
问题 I'm writing a custom UITabBar replacement, and I would like to know how to recreate the filter that the built-in implementation does with the UITabBarItem image - that blue shining on selected tabs and gray gradient on unselected ones. I guess it's a matter of using the source image alpha value as a mask and overlay it with a pre-made blue (or whatever color) shining image and another one grayed out, but I would like to know what is the best approach from a code point of view. Best, 回答1: Edit

adding a UITableView programmatically to a UIViewController

[亡魂溺海] 提交于 2020-01-11 18:51:50
问题 I'm loading a UIViewController into one of my Nav controller's hierarchies, which will contain some text and some images. At the bottom, I will want to create a expandable and collapsable tableview. First off, is this idea possible? If it is, how do I add it and where do I place the data source and delegate methods? Can I just make a separate subclass of the TableViewController and then add it to my ViewController as a subview? 回答1: Yes, you can create a UITableView whose delegate, datasource