Hi,
The following code allow to build an image from an UILabel:
let label = UILabel()
label.text = "test content"
label.backgroundColor = .white
label.layer.cornerRadius = 10
label.layer.masksToBounds = true
label.sizeToFit()
let format = UIGraphicsImageRendererFormat()
format.scale = 5
let renderer = UIGraphicsImageRenderer(bounds: label.bounds, format:format)
let image: UIImage? = renderer.image { rendererContext in
label.layer.render(in: rendererContext.cgContext)
}
This works perfectly on iOS but on Mac Catalyst the label text is very blurry as you can see in the image below.
Both images are created with the same exact code and have the exact same resolution of 460x103.
On top the iOS version and on bottom the Mac Catalyst version.
Note that not all of the image is blurry, but only the text. In the code I set a corner radius of 10 and you can see that the corner is rendered with an high resolution, like the iOS version. It's just the text that for some reason is blurry. It's like if the label text is rendered with a scale of 1 and then scaled up.
Someone know why? There is something I can do to improve the rendering of the text?
Thank you
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,
I'm trying to define the style of an UIButton using UIButton.Configuration in a Mac Catalyst app.
I was able to configure the component as I want except one thing.
I want to change the style of the button when the window is not active.
The default filled style automatically do this.
For example below you can see a button configured with
UIButton.Configuration.filled().
If the window become inactive (for example by activating another application) the color of the button change, like so:
Now, If I configure a button with this configuration:
var configuration = UIButton.Configuration.plain()
configuration.background.strokeColor = .gray
configuration.baseForegroundColor = .red
configuration.baseBackgroundColor = .clear
the button display with this configuration when the window is active:
but also when it's not active:
I want to change the text color from red to gray when the window is not active.
Someone know how to do it?
Thank you
Hi,
I have a controller with a UITableView.
If the user, on an iPad with a keyboard or on the Mac, press the tab key, the first cell is focused showing a border.
The user can then move the focus using the keyboard arrows.
That's ok.
The problem is that the cell is focused also when the cell is selected manually, i.e. by tapping on it.
It is possibile to keep the cell focus feature when the user use the tab key, but stop focusing the cell when it's activated directly by tapping on it?
Thank you
Hi!I currently developing a mobile website and found that Safari on iOS has some problems setting the focus on inputs when they are inside an iframe.When in a page you have many inputs you can tap on a field and then use the next / previous buttons on the keyboard to navigate between the fields. When the focus move to another input Safari scroll automatically the page centering the field in the page. This is great and works well.The problem is when the fields are inside a page of an iframe. In this case when you change focus from one field to another Safari has some kind of issue; the page “bounce” and the focused field is not centered in the page.I have made a video of a simple page that has this issue. In the first part of the video the page without the iframe is loaded and the focus works correctly. In the second part the page with the iframe is loaded and the issue is visible.http://www.dale1.ch/documents/safari_iframe_focus_issue.movThe code of the first page (testinput.html) where the focus is correctly handled is this:<!DOCTYPE html>
<html>
<head>
<title>Test input</title>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
</head>
<body>
<div><span>Input 1: </span><input type="text" tabindex="1" /></div>
<div><span>Input 2: </span><input type="text" tabindex="2" /></div>
<div><span>Input 3: </span><input type="text" tabindex="3" /></div>
<div><span>Input 4: </span><input type="text" tabindex="4" /></div>
<div><span>Input 5: </span><input type="text" tabindex="5" /></div>
<div><span>Input 6: </span><input type="text" tabindex="6" /></div>
<div><span>Input 7: </span><input type="text" tabindex="7" /></div>
<div><span>Input 8: </span><input type="text" tabindex="8" /></div>
<div><span>Input 9: </span><input type="text" tabindex="9" /></div>
<div><span>Input 10: </span><input type="text" tabindex="10" /></div>
<div><span>Input 11: </span><input type="text" tabindex="11" /></div>
<div><span>Input 12: </span><input type="text" tabindex="12" /></div>
<div><span>Input 13: </span><input type="text" tabindex="13" /></div>
<div><span>Input 14: </span><input type="text" tabindex="14" /></div>
<div><span>Input 15: </span><input type="text" tabindex="15" /></div>
<div><span>Input 16: </span><input type="text" tabindex="16" /></div>
<div><span>Input 17: </span><input type="text" tabindex="17" /></div>
<div><span>Input 18: </span><input type="text" tabindex="18" /></div>
<div><span>Input 19: </span><input type="text" tabindex="19" /></div>
<div><span>Input 20: </span><input type="text" tabindex="20" /></div>
<div><span>Input 21: </span><input type="text" tabindex="21" /></div>
<div><span>Input 22: </span><input type="text" tabindex="22" /></div>
<div><span>Input 23: </span><input type="text" tabindex="23" /></div>
<div><span>Input 24: </span><input type="text" tabindex="24" /></div>
<div><span>Input 25: </span><input type="text" tabindex="25" /></div>
<div><span>Input 26: </span><input type="text" tabindex="26" /></div>
<div><span>Input 27: </span><input type="text" tabindex="27" /></div>
<div><span>Input 28: </span><input type="text" tabindex="28" /></div>
</body>
</html>This is the code of the page that has the issue (testinput_iframe.html):<!DOCTYPE html>
<html>
<head>
<title>Test input</title>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
</head>
<body>
<iframe src="/testinput.html" />
</body>
</html>The issue is present in Safari on the iPhone, iPad and the xCode Simulator from version 8.4 to version 9.2.Someone know if this is a bug? There is way to fix it in css or javascript?Thanks and sorry for my english! 😉
Hi,
I want to set the glyphImage property for an annotation view (MKMarkerAnnotationView) of a cluster annotation (MKClusterAnnotation).
Using the below code, inside the marker I get, instead of the glyphImage, the standard cluster number.
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if let cluster = annotation as? MKClusterAnnotation {
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "GroupMapClusterAnnotation")
if annotationView == nil {
annotationView = MKMarkerAnnotationView(annotation: cluster, reuseIdentifier: "GroupMapClusterAnnotation")
}
(annotationView as? MKMarkerAnnotationView)?.glyphImage = UIImage(systemName: "star.fill")
return annotationView
}
}
I think that the problem is that if you keep the glyphText property empty, MapKit automatically set it with the number of the cluster member annotations.
The documentation for glyphImage says:
Use this property or the glyphText property to specify the marker balloon content. If you specify both an image and text, MapKit displays the text.
So, MapKit is setting glyphText with a value an therefore the glyphImage property is ignored.
How can we use the glyphImage property for a cluster annotation?
Thank you
Hi,
I have a controller where the user can search for map locations or points of interest by typing inside a search box.
To retrieve the list of results I set the queryFragment parameter of a MKLocalSearchCompleter with the search content.
This correctly gives me back a list of MKLocalSearchCompletion of locations and points of interest.
When a user tap on one of this locations, I need to load the coordinates.
In order to do that I do a MKLocalSearch passing the selected MKLocalSearchCompletion, like so:
let item = items[indexPath.row]
let request = MKLocalSearch.Request(completion: item)
let search = MKLocalSearch(request: request)
search.start { (response, error) in
//Do stuff with the result.
//For some specific items I receive an MKErrorDomain 4 error.
}
This works most of the time, but for some specific items the MKLocalSearch call return the error:
Error Domain=MKErrorDomain Code=4 "(null)" UserInfo={MKErrorGEOError=-8}
This error correspond to "placemarkNotFound", ie MapKit is not able to find a placemark for the specific MKLocalSearchCompletion.
I just don't understant why this should be the case.
The MKLocalSearchCompletion is returned by MapKit.
If it is returned by MapKit then a corresponding placemark should exist, right?
Why then is MapKit unable to perform a local search on it?
The problem now is that I present the user with a list of completions returned by MapKit but tapping some of them nothing happens because I cannot determine their respective coordinates.
Why is the search failing sometime? I miss something?
Thank you
Hi,
I need to generate the image of a map at a specific resolution.
I tried to use the following code:
let options = MKMapSnapshotter.Options()
options.size = CGSize(width: 300, height: 200)
options.scale = 1.0
options.mapRect = mapRect
let mapSnapshotter = MKMapSnapshotter(options: options)
if let snapshot = try? await mapSnapshotter.start() {
let image = snapshot.image
}
Since I specified the options.scale to be 1 I expect the image resolution to be exactly 300x200 pixel (and with a scale of 1).
Unfortunately the resulting image has a scale factor of 3 (on an iPhone) and the actual resolution is 900x600 pixel.
I also tried, instead of using the scale option, to set the traitCollection option, like this:
options.traitCollection = UITraitCollection(displayScale: 1.0)
but I still get a 3x scale image with a resolution of 900x600.
Why is the scale option ignored? I miss something?
Thank you
Hi,
I just discovered a weird bug with UITextView on iOS 16 beta 4.
For some reason now, when the scrolling is disabled, the intrinsic content size of the text view is considering the line spacing even when the textview is empty.
For example, in the below code we are setting a big lineSpacing of 50 to the text view typingAttributes attribute.
class ViewController: UIViewController {
@IBOutlet weak var textView: UITextView! {
didSet {
//Let's set the textView typingAttributes with a lineSpacing of 50.
var attributes = [NSAttributedString.Key: Any]()
let paragraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 50
attributes[NSAttributedString.Key.paragraphStyle] = paragraphStyle
attributes[NSAttributedString.Key.font] = UIFont.preferredFont(forTextStyle: .body)
textView.typingAttributes = attributes
}
}
}
On previous iOS versions, everyting it's ok and the line spacing is added only when there are more than one line (see below image).
However, on iOS 16 beta 4, the line spacing is added also when the content is empty (see below image on the left). A soon as we type something the height collapse to the correct height (see below image in the center).
Is this a new expected behavior or a bug? If it is a bug, someone has found a temporary fix for that?
Thank you
Hi,
I'm looking for a way to do something when the user presses the window red close button on a Catalyst app. For example, in some cases, I need to display an alert and prevent the window from closing.
On AppKit we can use the windowShouldClose delegate method of NSWindowDelegate. Unfortnuately this is not available on Catalyst.
Did someone found a way on Catalyst to prevent a window from closing? Maybe there is a way to expose the AppKit NSWindowDelegate object?
Thank you
Hi,
I am faced with a strange problem with a Catalyst app that uses MapKit.
If the map is visible and I resize the window (causing the map the resize), sometime the app crashes with some Metal related error.
Is this a know issue between MapKit and Catalyst?
There is something I can do in order to prevent this crash?
Below you can find the error message and a screenshot of the thread that caused the crash.
Thank you
-[MTLDebugDevice notifyExternalReferencesNonZeroOnDealloc:]:2951: failed assertion `The following Metal object is being destroyed while still required to be alive by the command buffer 0x7f96de27f600 (label: <no label set>):
<MTLToolsObject: 0x7f96dde552e0> -> <BronzeMtlTexture: 0x7f96dc04c230>
label = <none>
textureType = MTLTextureType2D
pixelFormat = MTLPixelFormatBGRA8Unorm_sRGB
width = 2372
height = 1668
depth = 1
arrayLength = 1
mipmapLevelCount = 1
sampleCount = 1
cpuCacheMode = MTLCPUCacheModeDefaultCache
storageMode = MTLStorageModeManaged
hazardTrackingMode = MTLHazardTrackingModeTracked
resourceOptions = MTLResourceCPUCacheModeDefaultCache MTLResourceStorageModeManaged MTLResourceHazardTrackingModeTracked
usage = MTLTextureUsageShaderRead MTLTextureUsageRenderTarget
shareable = 0
framebufferOnly = 0
purgeableState = MTLPurgeableStateNonVolatile
swizzle = [MTLTextureSwizzleRed, MTLTextureSwizzleGreen, MTLTextureSwizzleBlue, MTLTextureSwizzleAlpha]
isCompressed = 0
parentTexture = <null>
parentRelativeLevel = 0
parentRelativeSlice = 0
buffer = <null>
bufferOffset = 0
bufferBytesPerRow = 0
iosurface = 0x0
iosurfacePlane = 0
allowGPUOptimizedContents = YES'
Hi,
I have a UITextView with allowsEditingTextAttributes set to true.
On iOS 15 and before, users can select part of the text and tap on the BIU button in order to set the text to bold, italic or underline. On iOS 16 the BIU button is missing.
How can the user change the formatting of the text contained inside an UITextView on iOS 16? There is something I need to specify on UITextView?
Thank you
Hi!I have a model with an antity that have a property that use the "Allows External Storage" option. For some reason the framework does not handle the files inside this directory correctly when some of the files have the SAME data.Basically the issue is:- You have an entity with a binary property that use the “Allows External Storage” option.- You create some entities and for every entities you put the same data in the binary property.- After saving Core Data will create inside the _EXTERNAL_DATA folder a file for every entity data.- You delete all the entities from the store.- Core Data will delete only a single file and all the other files are left in the directory forever.So if you create for example 10 identical entities (same data) with 1MB of data for every entity, after deleting all the entities from the store your _EXTERNAL_DATA folder will still contain 9MB of orphaned data that will stay there forever. 😟This bug is present in iOS 7, iOS 8 and iOS 9 beta 5.I have made a sample project that illustrate this behavior:http://www.dale1.ch/documents/delete_external_data_sample_project.zipI have filled a bug report (18319761) the 12 September 2014 with all the informations needed to reproduce the issue but unfortunally is still Open and I didn't received any feedback from Apple.Alan
In a Core Data store I have a binary data attribute with “Allows External Storage” set to true. Everything work as expected, i.e. the data of this attribute is saved inside the _EXTERNAL_DATA folder. For every data stored into that attribute, a file is created inside _EXTERNAL_DATA with a UUID as file name and without extension. That's expected.
For some reason the _EXTERNAL_DATA folder of a particular user was full of files with an “.interim” extension.
Somebody know what are this files? In which cases files are saved with the ".interim" extension? Do we need to do anything with these files? Can they be deleted?
Thank you
I have an entity named Image with a binary attribute named imageData.
I need to cycle trough all Image objects and do something with the data contained inside the imageData attribute.
This is the code:
for image in managedObjectContext.allImages {
autoreleasepool {
var imageData = image.imageData
}
}
I have a lot of objects and every imageData has something like 500KB of data for a total of 3GB of data.
The problem is that each time the imageData attribute is used, the data go into memory and not released until the loop is done. This is causing the memory to grow up to 3GB crashing the app.
I also tried to turn the object into a fault when I'm done with it by calling refresh(_:mergeChanges:) but nothing changes:
for image in managedObjectContext.allImages {
autoreleasepool {
var imageData = image.imageData
managedObjectContext.refresh(image, mergeChanges: false)
}
}
How can I cycle trough all objects without filling up all the memory?
Thank you
Hi,
I'm testing one of my app on iOS 14 with Xcode 12 beta 3 (12A8169g) and I have a problem with my storyboards.
Xcode give me this error for all the storyboards that contain a split view controller:
An internal error occurred. Editing functionality may be limited.
The log generated by the Xcode "Report a bug" button say:
Exception name: NSInvalidArgumentException
Exception reason: UITabBarController is unsupported as viewController for -[UISplitViewController setViewController:forColumn:] in Primary column
It worked correctly on Xcode 12 beta 2.
Has anyone encountered the same problem and found a way to fix it?
Thank you