iOSOpenDev Including Images - ios

I am trying to use iOSOpenDev to build a jailbreak tweak. I am used to doing everything in programmatically and without using interface builder. I want add a background to my UIButton by doing this.
button setBackgroundImage:[UIImage imageNamed:#"arrow.png"]forState: UIControlStateNormal];
When I run the code on my iPhone, the background image is not displayed. I have the image in the same directory as my tweak.xm file. How would I give the UIButton a background of this image? I would easily be able to in a regular application by adding it to the project assets, but there isn't one in the Logos template.
Any help would be appreciated.

Related

UIButton with no image doesn't highlight in Xcode 7 - iOS 9.2

I'm making my first app in Swift and I noticed that when I create UIButtons in the storyboard when selected (highlighted) in the app they only change background if the button is an image.
I was wondering if there is any way in Swift to change that so that even the buttons with no image will change their background to a darker background.
Thanks for the help.
UIButton's default behaviour is to change its background on click.
try dragging a new UIButton on Interface Builder, and run the program without doing any changes to the button.
With your specific button, inspect it in Interface Builder and check that its type is System, otherwise you don't get that default behaviour.

Can I use the default UIBarButton icons provided by Apple in other assets of my app?

Like in UIButton or a UIImageView etc..
If so how do I do that using the StoryBoard or in a Xib
I am able to use the default icons inside UIBarButton items but cannot look them up in normal buttons . A solution using Storyboard would be really nice
In order to use them you need to extract them using a handy little app called (fittingly enough) iOS Artwork Extractor. I use it all the time when I want to mimic iOS system behaviours.
Download the Xcode project at:
https://github.com/0xced/iOS-Artwork-Extractor
Or another way:
The Other.artwork file is in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/ (you need the SDK).
Use the "iPhoneShop-1.3.jar" program -- available currently here to extract all of the images into a directory.
java -jar iPhoneShop-1.3.jar ARTWORK Other.artwork EXPORT Other
No you cannot use UIBarButtonItem on other as subview like UIButton. UIBarButtonItem can only over UINavigationBar.

UIButton: set background color (NOT IMAGE) for selected-highlighted UI state

I'm using Xcode 6.1.1
Is it possible to set the background colour in code for the selected/highlighted state for UIButton? - Not a background image!
I'm using ID's for colors (e.g. #"theme.brand.primary") that are linked to a json file i.e. .plist file
I've done it for setTitleColor UIControlStateHighlighted which works fine... example code:
[button setTitleColor:[config getColour:#"button.text.pressed-state"] forState:UIControlStateHighlighted];
However I want the colour of the button to change not the title.
There is no option for setBackgroundColor:forState: ???
Does anyone know if theres a simple way to do this?
Can you not just check for highlighted?
if (myButton.highlighted) {
myButton setBackgroundColor.......
}
I have open-sourced a class, STAButton, to fill this functionality hole. Available under the MIT license. Works for iOS 7+ (I have not tested with older iOS versions).

Programatically Set UIImage Animation with WatchKit

I can't seem to figure out how to programmatically set a new image, via the outlet, and make it start animating.
Sequence
zeroEntering0.png
zeroEntering1.png
zeroEntering2.png
zeroEntering3.png
zeroEntering4.png
I imported the sequence of images into the Image.xcassets inside the WatchKit App
I can set the image in the interface builder to "zeroEntering" and set animating to "Yes" and it works correctly.
However, I want something more dynamic, I need a button press to choose a new animation sequence and start it off. If I try and set the image programmatically using the same name from the interface builder, the UIImage is nil.
What naming convention should I use when programmatically setting the UIImage? "zeroEntering", "zeroEntering0", "zeroEntering.png" or "zeroEntering0.png"
I tried using the two non-nil options and the image did not animate and went black.
The answer is subtle and definitely got my wheels spinning for too long.
According to this beautiful article,
You should use setImageNamed(:) when the image you want to display is either cached on the watch on is in an asset catalog in the watch app’s bundle, and use setImage(:) when the image isn’t cached — this will transfer the image data to the Apple Watch over the air!
So, I kept my images in the assets catalog on the watch app, and switch to use,
[self.testImage setImageNamed:#"zeroEntering"];
[self.testImage startAnimatingWithImagesInRange:NSMakeRange(0, 4) duration:0.2 repeatCount:100];
Set the image as [UIImage imageNamed:#"entering"] then call startAnimatingWithImagesInRange:duration:repeatCount:
Check it out here: https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceImage_class/#//apple_ref/occ/instm/WKInterfaceImage/startAnimatingWithImagesInRange:duration:repeatCount:
Make sure to follow the tips here: https://developer.apple.com/watchkit/tips/

How to get system images programmatically? (example: disclosure chevron)

I want to create UIImageView with some system-image in it. (Example: the disclosure chevron image, etc.). How can I do so programmatically?
Note: I don't want to download the image and add it to the project, I want to fetch it from the user programmatically / from the Interface Builder.
From iOS 13 and Xcode 11 you can get system images by giving system name.
let image = UIImage(systemName: "info.circle")
Reference : UIImage Apple Documentation
If you mean you can to set the button to use the system disclosure icon, just do as #middaparka suggested and use this:
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
If you're asking how you can access the image directly, you can't do that. This is your only option: Use default apple icons for pdfs and docs in iOS app?
I think iOS-Artwork-Extractor is the tool you are looking for. It lets you extract the artwork into png files.
There is no clean programmatical way to access the images of system buttons. Quote from the documentation of the UIButton.imageView property:
The value of the property is nil for system buttons.
You may do an off screen rendering of the views and extract the resources on the fly but that's a very shaky approach. It's better to extract every asset you need and use them as intended. You'll suffer much more in the end with the programmatic way.

Resources