Embedding a custom font in a screensaver - objective-c

I can't figure out how to include a font in my Mac screensaver.
I did this following tutorial, Embed font in a mac bundle, but my [NSFont fontWithName:size:] still returns null.
I don't really know where to start.
Any thoughts, solutions?
Thank you

The example you're following works for an application. The problem is that you're building a screensaver bundle. Those are not applications unto themselves, they are loaded by separate application. Apparently, the ATSApplicationFontsPath key, as its name implies, is only used when loading an application.
You will have to write code to enumerate the font file URLs in your bundle and register them. You can use -[NSBundle URLsForResourcesWithExtension:subdirectory:] and CTFontManagerRegisterFontsForURLs() for that.

Related

Any Fresher Ways to Access Images in Asset Catalog Programatically?

I'm using an asset catalog with Xcode 5.1 and making an app for iOS 7 and above. The idea behind an asset catalog is that you can call the images whatever you want and the catalog associates the image with the correct device and orientation. In the background, Xcode apparently renames the files along the scheme mentioned here. However, it appears that there is a steady supply of problems accessing the files programmatically (here, here or especially here) without running into memory problems (e.g. here).
So I have the assets in my catalog and the launch images are called correctly. But I also want to use the launch images as background images, so I need to call those programmatically. In principle all that I should need to do, if I understand the asset catalog concept correctly, is something along these lines:
- (void) selectBackgroundImage {
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"LaunchImage"]];
}
And the OS should pick the correct launch image from the xcassets launch image set. However, this apparently only works if one uses the conventional names for the images, e.g. Default-Portrait#2x~iPad.png which defeats one claimed advantage of the asset catalog (any name you like) and may run into the aforementioned memory problems.
At this point, a few months after the referenced posts, are there better solutions? I know I can get rid of the asset catalog and access the files directly, or add a lot of work around code, or use the catalog along with the official file names, but none of these 'solutions' are in the spirit of what the asset catalog is supposed to do.

Custom font on iOS7 app which supports iOS 6

I have made an app which has several custom fonts, but i'm struggling to make it work on ios6 devices, i have added them in myApp-Info.plist and it works without any problem on labels and buttons and everywhere except uiwebviews in ios7 , but in ios 6 it looks like the default font in everywhere and there is no change throughout the whole app in fonts. After searching couple of weeks, still haven't find any answer that would work.
Here is my code for assigning a font to label :
titleLable.font=[UIFont fontWithName:#"B Yekan" size:17];
I just encountered this problem, also, and found that in iOS 7, font names aren't case-sensitive; i.e., I was trying to use "ChunkFive-Roman", which worked in iOS 7 even though my code said "Chunkfive-Roman".
However, this doesn't work in iOS 6... I was getting the default font instead. Changing the font name to "ChunkFive-Roman" fixed it so that that the text was appearing correctly in both. (Note -- was using Simulator in both cases).
You have to follow the rules in this link, once you do it there u go..
Add your custom font into your project , i.e. Dragged the font's ttf file (CALIBRIZ_0.TTF) into your resource folder from finder and check the "copy file to project folder" option. )
Edit Info.plist: Add a new entry with the key Fonts provided by application.
For each of your files, add the file name to this array (Fonts provided by application)
Now set font to your label:
MyLabel.font = [UIFont fontWithName:#"Calibri" size:16];
http://blog.builtwithlogic.com/post/73503283890/installing-custom-fonts-on-iphone-and-ipad-ios-devices
Covers how to add fonts - Little confused though by your question you specifically mention iOS6 as the problem and UIWebView - Be interested to know what you mean by that piece?
Have you tried setting the fonts using UIAppearance ? or are you subclassing and amending the fonts as it could be that you've not done it right there. Could you supply some code showing how you setting you custom fonts throughout the app?
If you haven't already I'd ensure you've followed the steps in that email and then add a custom category to UIFont to pass back a specific font. If you haven't already done so I would also set the fonts in UIAppearance for your labels, Titles etc this is the cleanest and most efficient way to do it throughout your application as you only need set it one and you can set differently based on how a for example Label is presented -in a tableview in a navigation bar etc.
here's a link to the official docs
https://developer.apple.com/library/ios/documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html
Appreciate this question is old but love to know if that helps.
I had a similar problem where the custom font would work in iOS7, but not iOS6.
The solution for me was to use the true font name not the filename.
To do this check the font name as shown in OSX's FontBook.
iOS7 allowed me to use the the filename (less the .ttf suffix), but iOS6 wanted the true font name as shown in FontBook.
For example for a font named CustomFont.ttf .....
I followed all the steps listed by others here to add the font to my app, but then used it by referencing it as #"CustomFont".
When I added the font to my mac and looked at it in FontBook (mac utility), it was actually named #"Custom font" - with a space and a lower case letter.
Hopefully this helps someone else out there :-)
iOS 6 cannot do custom fonts. That is a new feature only available in iOS 7.

Very confused by a binding issue between a Cocoa app and a Movie Loader patch in Quartz Composer

I've been programming for a while, but just recently decided to start developing for Mac OS X. I feel like I've come to grips with the basics of Objective-C and Cocoa development over the past week. I'm planning on making graphics apps, and as such am currently in the process of learning how to control Quartz compositions through a Cocoa app. I went through the tutorial that apple offers (with the Mac Engravings composition), and was able to create that just fine. In order to make sure that I truly understood what I learned, I decided to create my own composition and link it to a slightly more complicated Cocoa application.
Essentially, I have a composition that loads a movie or image through a Movie Loader patch, at which point it applies various filters to the frames before outputting it. In my Cocoa app, I've written code (or rather copied and pasted from other apple examples) that lets a user pick a file using an NSOpenPanel object. The filepath of the file they pick gets placed in a text-box that I placed in the app's window using Interface Builder. I binded the value of said text-box to the "Movie_Location" key in my composition, which is a published input in the Movie Loader patch that I'm using. However, no matter what I do, movies and images aren't loaded into this composition no matter what I try. The only thing that gets displayed is the default image that I have saved in that input from Quartz Composer (or nothing if I leave it blank before publishing).
I've added a Clear Color patch to the composition and binded that to a colorwell in my UI, and that successfully changes the color in my display, so I know that the composition and my Cocoa app are communicating. I've spent numerous hours at this point trying to figure out what's going on, and I've just about given up. Does the Movie Loader have any weird behaviors that I'm not aware of, or is there something obvious that I seem to be missing? I'd really appreciate any help or advice from anybody.
Thanks for reading through this...
Best,
Sami
There are two things I can think of as reasons why it is doing this:
The file path isn't formatted incorrectly. Try checking backslashes, colons, etc.
The box isn't updating the value. Try literally clicking in the text field and hitting enter.
That's all I can think of without seeing your quartz composition and/or code.
EDIT:
Check the other continuous box, in the general properties.
I figured this out yesterday. spudwaffle's second idea is what was going on. If I were to type a filepath in and hit enter, it would work just fine. I got this to work properly by just removing the bind and instead using the setValue:keyInPath: function that a patch controller offers. That said, is there some way to force a text-box to update? I remember seeing a "continuously update" or something like that button within the bind sub-menu in the inspector, but my code didn't work with that checked either.
Thanks to those of you that tried to help me! I really appreciate it.
Best,
Sami

How to get system icons in iOS

I want to use icons like opened/closed folder in my table (UITableView)?
UPD:
For example, in Java you can get a standard image "folder" and use it in the FileTree:
new
DefaultTreeCellRenderer().getDefaultClosedIcon()
And also can use the constants of L&F (colors, styles, icons).
In the iOS, I found only these standard icons.
But not folder icons...
I'm not quite sure exactly what you want - the folder icon from iOS? Could you explain a little better?
If it is a folder icon that you want, there's no quick way to get it from code - doing so would use private API's and your app is likely to be rejected from the app store.
If you want something like a folder icon, a good way to get it would be by taking a screenshot of the iPhone simulator and editing it to the right size etc.

Themes in Adobe AIR

What is the best way to skin/theme an AIR application. For example, I want to use a dark/blackish theme instead (similar to Tour de Flex) instead of the default gray one.
The ScaleNine themes are a good place to start, find one that is sort of like what you want, plug it into your app, and gradually replace the colors, images, and controls with your own.
http://www.scalenine.com/
I'm only just getting started in AIR as well, but if you're using Flex check out the Flex in a Week video series. There are several videos that cover creating custom MXML components and item renderers, which effectively let you skin your application.
You can also use CSS to style your app.
First you need to set the system chrome property in the air application properties file to none.
<initialWindow>
...
<systemChrome>none</systemChrome>
...
</initialWindow>
If the main file in your air app is named Main.mxml, then your application properties files will be named Main-app.xml. This file is not hard to find, it should be in the same location as the Main.mxml file.
By setting this property to none you are saying that you do not wish your air app window to take the style of the OS windows in which the app is running.
Since this property is set to none, the chrome for the air app will have to come from your Main.mxml file, which should be a WindowedApplication
Use the titleBarBackgroundSkin attriubute of the WindowedApplication To set the skin for the air app. titleBarBackgroundSkin defaults to "mx.skins.halo.ApplicationTitleBarBackgroundSkin"