I checked the official documentation but I could not see a specific colour to use for the icons sitting in Safari's toolbar (e.g. "toolbar-icon-72").
I have tried a number of different greys and although I have the one that looks good to my eye, it may be a little off to others. So I was wondering if there was a recommended colour ?
I also tried using the bundled Digital Colour Meter in macOS to determine a single grey colour, but of course, at the pixel level, anti-aliasing leaves that very much down to interpretation.
I have gone with 141/141/141 (RGB).
Post
Replies
Boosts
Views
Activity
I am trying to design a Safari extension to register a mouse-click on a webpage's image to automatically download that image when clicked on (whilst holding down the Command key).
function handleImageClick(event) {
if (event.target.tagName === 'IMG') {
const imageUrl = event.target.src;
const link = document.createElement('a');
link.href = imageUrl;
link.download = 'image';
link.click();
}
}
document.addEventListener('click', handleImageClick);
However, I am having no luck and wonder if it's because all functionality is limited to the toolbar popover ?
Using the CIFilter.qrCodeGenerator() to create a QR code I wanted to change the colours dynamically to suit Light/Dark mode, but was unable to figure out how to achieve this, is it possible please ?
struct QrCodeImage {
let context = CIContext()
func generateQRCode(from text: String) -> UIImage {
var qrImage = UIImage(systemName: "xmark.circle") ?? UIImage()
let data = Data(text.utf8)
let filter = CIFilter.qrCodeGenerator()
filter.setValue(data, forKey: "inputMessage")
let transform = CGAffineTransform(scaleX: 2, y: 2)
if let outputImage = filter.outputImage?.transformed(by: transform) {
if let image = context.createCGImage(
outputImage,
from: outputImage.extent) {
qrImage = UIImage(cgImage: image)
}
}
return qrImage
}
}
Further, I cannot see an option for the different modes and assume that any colour could be used, which would be a lot better for me.
ref: https://developer.apple.com/documentation/coreimage/ciqrcodegenerator
Working from Apple documentation I wanted to apply the CIPixellate filter to a SpriteKit Node and found that SKEffectNode grants access to CoreGraphic's filters and could be a good bridge.
I can get the image to pixelate, but I am looking for a smooth transition between the two stages and believe that I am having trouble with the "simd_smoothstep" function:
let pixelateNode: SKEffectNode = SKEffectNode()
let testSprite = SKSpriteNode(imageNamed: "testSprite")
let filter = CIFilter(name: "CIPixellate")!
let inputScale = simd_smoothstep(1, 0, abs(0.9))
let filter = CIFilter(name:"CIPixellate", parameters: [kCIInputImageKey: testSprite, kCIInputScaleKey: inputScale])
pixelateNode.filter = filter
pixelateNode.shouldEnableEffects = true
addChild(pixelateNode)
pixelateNode.addChild(testSprite)
ref: https://developer.apple.com/documentation/coreimage/customizing_image_transitions
ref: https://developer.apple.com/documentation/coreimage/customizing_image_transitions
nb. this is a repost in the SpriteKit forum. The old post can be removed: https://developer.apple.com/forums/thread/684687
Working from Apple documentation I wanted to apply the CIPixellate filter to a SpriteKit Node and found that SKEffectNode grants access to CoreGraphic's filters and could be a good bridge.
I can get the image to pixelate, but I am looking for a smooth transition between the two stages and believe that I am having trouble with the "simd_smoothstep" function:
let pixelateNode: SKEffectNode = SKEffectNode()
let testSprite = SKSpriteNode(imageNamed: "testSprite")
let filter = CIFilter(name: "CIPixellate")!
let inputScale = simd_smoothstep(1, 0, abs(0.9))
let filter = CIFilter(name:"CIPixellate", parameters: [kCIInputImageKey: testSprite, kCIInputScaleKey: inputScale])
pixelateNode.filter = filter
pixelateNode.shouldEnableEffects = true
addChild(pixelateNode)
pixelateNode.addChild(testSprite)
ref: https://developer.apple.com/documentation/coreimage/customizing_image_transitions
Using a relationship I am able to pair entries together, but cannot figure out how to exactly match the customer that I am looking for, nor to create new records without overwriting the old ones.
let userEntryRecord = NSEntityDescription.entity(forEntityName: “Record”, in: managedContext)!
let userEntryCustomer = NSEntityDescription.entity(forEntityName: “Customer”, in: managedContext)!
let dataRecord = NSManagedObject(entity: userEntryRecord, insertInto: managedContext) as? Record
let dataCustomer = NSManagedObject(entity: userEntryCustomer, insertInto: managedContext) as? Customer
dataRecord?.year = “2021”
dataRecord?.month = “March”
dataRecord?.addToCustomer(dataCustomer ?? Customer())
dataCustomer?.age = 20
dataCustomer?.gender = “male”
dataCustomer?.country = “UK
I would like to search for all records for October 2023, with those of ages between 20-40, how do I create a fetch request for that ?
On top of that, I need to amend records, and of course create new years to attach records to, something I am having difficulty with.
I am looking to integrate my code with CoreData. Presently I have the following of which allows a worker to check their requirements against an advert e.g. if the worker needs x3 sponges to clean a bathroom, then the advert must provide those sponges, but the worker can only work on set days:
var cdExample: [CleaningRota] = [bathroomMonday, kitchenFriday]	//
[Full sample code](https://developer.apple.com/forums/content/attachment/648c2166-46f3-44a3-bfc7-5e36f3d38721){: .log-attachment}
CORE DATA EXAMPLE
		let personAvailable: [Person] = [kath, mavis]
		//CORE DATA EXAMPLE : WORK ON OFFER
		for work in cdExample {
				//WORK TOOLS PROVIDED ON SITE
				for toolsAvailable in work.tool {
						//PERSONS AVAILABLE TO WORK
						for person in personAvailable {
								//PERSONAL REQUEST : SPECIFIC WORK DAY
								if person.avilability == work.day {
										//CHECK PERSON TOOL REQUIREMENTS FOR JOB
										for personRequirement in person.materialsNeeded {
												//CYCLE THROUGH TOOLS WORKER NEEDS ON SITE
												if personRequirement.tool == toolsAvailable.name {
														//CONFIRM TOOLS WORKER NEEDS ARE FULLY PROVIDED
														//AVOID CHECKING SAME STOCK TWICE IF CONDITION PREVIOUSLY MET
														if personRequirement.quantity <= toolsAvailable.stock && personRequirement.met == false {
																print(">>0> \(person.name)")
																print(">>1> \(personRequirement.tool) : \(personRequirement.quantity)")
																print(">>2> \(toolsAvailable.name) : \(toolsAvailable.stock)")
																personRequirement.met = true
																person.materialID.append(toolsAvailable.id)
														}
												}
										}
								}
						}
				}
		}
As the adverts and requirements pile up this kind of system will not scale very quickly. I would like to know if there is a better way to model this data, or to check conditions.
I plan to pull the cdExample from CoreData, and am unfamiliar with using it. Being a proprietary Apple Framework I do not know if anyone will help me here, but if not then how best to achieve what I want without a pyramid of doom (which I don't mind), is there a better way please?
I also need to remove the stock, which I ran into trouble with as I had too many loops and hit a bug in Xcode, so I think I'm doing something wrong with all of these loops ?
Is there any protocol conformance to utilise the Full Screen capture feature present in iOS 13 as seen in apps like Safari and Mail?