I have several iOS puzzle apps, written with Objective-C using QuartzCore.
I would like to include a quick animation showing how to solve the puzzle. Non interactive is OK.What would be a small format to use? Gif-anim? I would like to use minimal coding (pretty much just a 'do not show again' UIButton) and have the entire thing done with graphics file/s. Anyone has any suggestions? Maybe using web-kit?Thanks!!
What I ended up doing is following the suggestion of Mahal.
I created a view with a simple background image, and four buttons: Back, Close, Next slide and Previous slide.
At the start, you can choose to see tutorial. Otherwise, it's available from the help screen.Sharing flowchart below...
What about a UIImageView and an array of PNGs?
UIImageView
#property(nonatomic, copy) NSArray *animationImages
#property(nonatomic) NSTimeInterval animationDuration
Related
I just started my first project in iOS, recently I have encountered a problem in the UI when i receive it from the designer.
The expected output is shown as below and i can do most of it without any problem.
Now the problem came when I am about to implement this :
As the number of colour varies depending on item, I cannot add it like what I did for the share and love button I have no idea how can i implement something like this, I have look through the Object Library in the storyboard and cannot find any that can produce the output as expected .Any helps and guides are much apprecited!
I've worked with Xcode and iOS on a few personal projects and have always used non-object-oriented designs for everything... just because I've been doing mostly learning/experimenting with things.
Now I've been trying to implement some object oriented design into one game I've made previously. The idea is, I have a space ship that can shoot bullets. In the past I basically added the UIImageView to the storyboard and then connected it to the .h file and from there did things on it like move it around or whatever (using CGPointMake).
The idea now is to make a method (and a whole other class soon) that will create a UIImageView programmatically, allocate it, add it to the superview etc... I've got this working so far, easy stuff, but the next part is a bit harder. Where do I store this local variable "bullet"? I've been saving it to an NSMutableArray and doing the following:
(actually here are the methods that I have)
-(void)movement {
for (int i = 0; i < [array1 count]; i ++) {
UIImageView *a = [array1 objectAtIndex:i];
a.center = CGPointMake(a.center.x + 2, a.center.y);
if (a.center.x > 500) {
[array1 removeObjectAtIndex:i];
[a removeFromSuperview];
}
}
}
-(void)getBullet {
UIImageView *bullet = [[UIImageView alloc] initWithFrame:CGRectMake(ship.center.x + 20, ship.center.y - 2, 15, 3)];
bullet.image = [UIImage imageNamed:#"bullet2.png"];
bullet.hidden = NO;
[self.view addSubview:bullet];
[array1 addObject:bullet];
}
(by the way, array1 is declared in the .h file)
and theres a timer that controls the movement method
timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:#selector(movement) userInfo:nil repeats:YES];
first question is: what is the correct way of doing this? Storing a bullet for example until it is removed from the superview, should I store it another way?
and another question is, when I remove a UIImageView from the superview, does that remove it from memory so its not using up system resources?
Thank you for the help!
(will update if I Think of other questions
UPDATE
I would like to point out that currently this is not functioning correctly. When I click on a "shoot" button that I have created (which basically calls the getBullet method) the bullet appears but does not move.. not sure why. This is part of why I'm asking this question as well.
I offer you a totally different solution. Instead of using the built in UIKit to perform graphics calculation and move things around the screen, try using an external framework other than UIKit. The UIKit framework is really good at its intended job, which is more oriented around a touch based user interface than game development. The following is pulled from the UIKit documentation from Apple.The UIKit framework provides the classes needed to construct and manage an application’s user interface for iOS. It provides an application object, event handling, drawing model, windows, views, and controls specifically designed for a touch screen interface.As you can see, UIKit was made for the purposes of slick user interfaces, not animating sprites (spaceships, bullets) around the screen.
The best alternative is to look down another path. The first thing to go to would be SpriteKit. Made by Apple and already included in Xcode, SpriteKit is the perfect tool for your job. Made specifically for game development, it has the ability to seamlessly animate many sprites on screen at a time (bullets in your case) and has a built in physics engine. It is very easy to learn, and has the potential to turn you idea into a great game.
The link to the SpriteKit documentation can be found here.
Every time when we add UIImageView or simple UIView with some custom CALayer objects added to "layer" property to view hierarchy, there are some different scenarios:
1) all images (in uiimageviews and calayer) are drawn with random delay
2) some images are drawn, but some not, when we perform a simple touch event anywhere - they appear
3) some images are not drawn and they won't appear after simple touch events, the only way make them to appear is to minimize the app and to expand it again.
The last case appears much less than two others. That problem occurs only on iOS7, iOS 4.3-6.1 is totally OK. We have viewed a lot of possible solutions but they were pretty primitive and none of those helped.
Any help would be appreciated! Thanks in advance!
we solved the problem. For everyone, who has the same problem, - all you need is to create CALayer and UIImageView objects on main thread, while UIImage objects still could be created in background thread. All these fixes are needed only in iOS 7
I want to start by saying that i would post this question on the Apple Dev Forums but because of the hacking attempt fiasco , or whatever that was, the forum has been offline for almost 2 weeks now and i need a solution for this as soon as possible.
In iOS 7 the UIDatePicker looks like this :
and a client asked to look like this :
(basically inverted).
I've tried a few things:
Setting the background to black and looping through all the view's subviews until i reach the labels that show the date itself and change their color to white. The problem is that The view has only one subview, and that subview doesn't have any subviews of it's own. So this solution doesn't work. (it did in ios6).
Applying a filter to the view's CALayer. The thing is that this is only possible on OS X not on iOS, for some unknown reason.
Playing with UIApperance protocol. From what i've read this should work but what i've tried didn't and i don't have extensive experience with this to figure out why not.
Any ideas what i can try? Is this even possible? Did i made a mistake in my approach of the problem?
Try this out :
Put this code in -(void)viewDidLoad
[datePicker setValue:[UIColor whiteColor] forKey:#"textColor"];
Swift:
datePicker.setValue(UIColor.white, forKey: "textColor")
Don't know if this is still relevant but on Swift 3 / Xcode 8 you can simply do this:
let datePicker = UIDatePicker()
datePicker.datePickerMode = UIDatePickerMode.date
// Sets the text color
datePicker.setValue(UIColor.white, forKey: "textColor")
// Sets the bg color
datePicker.backgroundColor = UIColor.black.withAlphaComponent(0.6)
textField.inputView = datePicker
I spent quite a bit of time struggling with the same problem. At first, I've put a UIDatePicker on a black background and was wondering why it is invisible...
I ended up placing a white UIView as a background for the date picker, so while the whole view is black, the date picker is white. It actually looks okay, although thankfully I don't have a client who would dictate the design.
One possible argument for a client: the old, pre-iOS7 date picker, also had a predefined non-customisable background.
What you want is possible, but it will be called Custom Date Picker.
Below is the link where you will find what you wanted.
https://www.cocoacontrols.com/controls/simpledatepicker
If you need more, take a loot at below link.
https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=datepicker
Well I understand your frustration, but iOS7 is under NDA. Usually this kind of views are made using layers, beacuse of sublayerTransform that can make perspective giving the idea of 3D. I would check sublayers if you don't see subviews.
The other poin is that I would not hack too much views/layers hierachy, ios<=6 to ios7 transition shown that hacking isn't a good idea.
UIAppereance protocol is probably the way to go, becauase it makes you change what you can change (without screwing that in the future), maybe you can set a backgroundImage, try to set a 1x1pixel of a blck color png, you should also see an attributed string property, or text property.
I dont think its possible to do that directly by changing the properties of the default UIDatePicker , although you can use custom controls to do it.
This might help,
MWDatePicker - https://github.com/mwermuth/MWDatePicker (Found it in cocoa controls -https://www.cocoacontrols.com/controls/mwdatepicker)
according to the iOS Design Resources:
You cannot customize the appearance of date pickers.
I would suggest one of the below:
Redesign your UI to use the black text
Use a customer datepicker
You should tell your client that his suggestion is against the design principles of iOS 7, which indeed it is. I am not a great fan of iOS 7 myself, but we should all give it a go. Your client should accept the standard iOS 7 UI provisionally, until he is in a position to make an informed judgement. Designing an app based on his initial impressions is a recipe for disaster.
I'm a beginner in iOS and need some leads to do something that don't feel that easy to do ...
I have to change my design for a timer (elapsed time and remaining time) that looks this way :
To something that look this way :
Would you have any leads to give to me (except for the shadow color and offset properties that I already know) ? My principal guess for now is : How differentiate these 2 states : gray when no time and blue when there is.
Thank you in advance !
You're new to iOS development, so i'm not sure if it's a good idea to throw some 3rd party framworks at your head! but anyway, take a look at TTTAttributetLabel. I'ts a drop-in replacement for UILabel and lets you style the parts of a UILabel text differently, so it could fit for your needs above!
Download the framework from the given link and look at the example project provided with it. And don't forget to include the CoreText framework into your project. (see "How to add existing frameworks in Xcode")