Programming: Styling the Side Menu and Navigation bar

With the navigation and Side Menu the styling for this was a little bit more tricky than the styling that we had done for the rest of the App. As majority of the app was made programatically it was easy to see where we needed to add/change the styling eg colour, font size, font style etc but there were elements in the side bar that were created in storyboard.

The navigation bar was done programatically. Using the same colour scale that we used for the detail view all we needed to do was specify the exact RGB values. The line of code “barTintColor = UIColor(r: 76, g: 61, b: 61, a: 1) ” Is the code that changes the background colour for the navigation bar. From this we were able to speciy the colour for the burger  ( menu button), The line for that is “tintColor = UIColor.whiteColor()”. As there is an image within the navigation bar, you need a UIImage and from there you can frame how big you want it too be and what image to use. See below on the code that implemented the logo and the colour of the bar.

Screen Shot 2015-05-19 at 00.03.10From this it achieved the logo we wanted and the colours scheme to match our designs.

Screen Shot 2015-05-19 at 00.12.19The title for ‘filter categories” was styled in the same manner as before. The line of code “barTintColor = UIColor(r: 239, g: 233, b: 211, a: 1)” Is the code that changes the background colour behind the text. From this we were able to specify the colour for the text that was being displayed. The line for that is “.titleTextAttributes = [NSForegroundColorAttributeName: UIColor(r: 76, g: 61, b: 61, a: 1)]” See below full code. Note this is very similar to the styling of the navigation bar as it is but for the SideMenuController rather than ViewController.

Screen Shot 2015-05-19 at 00.21.18However to change the styling of the categories was needed to be done in the storyboard. This was only tricky because we had’t been using storyboard which meant I was a little bit ropy on how to change elements. Once I had realised where to go and how to change this elements it was plain sailing from there.

StoryBoard make it very easy to change the colours of each of the cells. You just need to click on the particular cell that you want to add some styling too then on the right hand side there are attributes such as background colour, tint, alpha levels which can all be adjusted to change the colour of each element you want to change.Note: you must make sure that you select the correct element you want to change colour.

Screen Shot 2015-05-19 at 00.25.55As you can see from above all the different cells have been coloured in. By selecting these cells you can also change any labels (text) that you have. This is done in the same way.

Screen Shot 2015-05-19 at 00.34.50It was important to make sure that the styling for the app matched the designs that were created and that we made sure that the colours and style conformed to the original style guidelines that were given to us by salisbury Cathedral and Red Balloon. We believe that the overall look for the navigation bar and side bar with the design icons that were made, meet the criteria of these guidelines.

Screen Shot 2015-05-19 at 00.38.40

Advertisements

Programming: App Icon and Splash screen

At the beginning we mentioned that our app is now going to be a separate app that is designed for iPad and going to be an installation that sits next to the Magna Carta document. We felt it necessary to provide Salisbury Cathedral with a complete packaged mobile application. That includes the actually app itself packaged with all the features the client wanted but also a Splash screen so when the app is opened (and for our case a long time) it shows an image of what the app is that’s being opened and an Icon to display on the launch pad on the iPad device.

Using the design guidelines set by Salisbury Cathedral we created these elements that conformed to the styling. Making sure that all the colours that were used were colours that we defined by the guidelines, all the fonts that were used were the same as the other work that will be displayed in the exhibition and making sure all image assets are copyright free or the cathedral hold the copy right for them.

Below the design that was created for the app icon. Using a online icon generator  I was able to make the image Icon on a square 1024x 1024 then it created the images into all the sizes that we need for the app icon to work.

magnacarta_icon

See below the exported images that all the different sizes that are needed within the app.

Screen Shot 2015-05-18 at 14.56.28Of which can be then put into the imageAssest’s appIcon file which when xCode builds the app it will take the images and compile them into the app. See below all the images in the asset file for an iPad device, we could also put in the sizes for iPhones however as we are explicitly making it for an iPad we haven’t included these.

Screen Shot 2015-05-18 at 16.04.03The method for the splash screen was very similar, however there wasn’t a website that created all the different sizes which would mean I would have to export all the different sizes myself. Luckily enough there is a LaunchScreen.xib that allows you to create the splash screen on a storyboard* which I added a UIImageView to place the same image as the app icon. See below splash screen.

splash However as the splash screen is scaleable depending on what iPad model it is. Therefore we have separated the background image to the text. This way the background can be scaleable but the text will remain the same size and centred by using constraints within the launchscreen.xib.

* This is a self-declared storyboard which is for a launch screen it has the same layout however it doesn’t hold the same properties as a storyboard.

Interpreting Designs for XCode

Extracting Assets The designs for our application were done using software such as Adobe Illustrator and Photoshop. This enabled designs to be easily modified and added to with every iteration of the project however the challenge of  transferring  these designs into a functioning app in  XCode is significant in meeting the needs of the client. One of these tasks involved the long process of recording the  X & Y coordinates of every clause hotspot going into the application. The clause hotspots were put into categories and colour coded which aided the programmers when creating the strings  associated with these categories Magna Carta Boxes Once all of the coordinates were recorded the programmers could then input and paste these values into Xcode which ultimately sped up their workflow. Here’s an example of a possible string;

Taxation Pink (#e000b8)

Clause 12:

  1. X = 6165, Y = 2528, Width = 1354 Pixels, Height 77 Pixels
  2. X = 398, Y = 2667, Width = 6212 Pixels, Height 77 Pixels

Clause 14:

  1. X = 5359, Y = 2788, Width = 2182 Pixels, Height 77 Pixels
  2. X = 398, Y = 2893, Width = 7143 Pixels, Height 77 Pixels
  3. X = 407, Y = 3010, Width = 6285 Pixels, Height 77 Pixels

Clause 15:

  1. X = 6683, Y = 2989, Width = 891 Pixels, Height 77 Pixels
  2. X = 398, Y = 3127, Width = 5256 Pixels, Height 77 Pixels

Clause 25

  1. X = 1710, Y = 3821, Width = 3256 Pixels, Height 77 Pixels

The coordinates were also recorded for other design elements such as the title bar and text fields. These were then published as a word document and accompanied with an PSD showing the guidelines for each of the assets which enabled the programmers to cross check that the coordinates were correct.

  1. Capture

Programming: Swift Vs. Objective-C

SWIFT: The NEW language to create applications on iOS and OS X.

Previously developers used Objective-C to program the apps that we love and use. However, in 2014 Apple created their own language for developers to use to create applications for iOS and OS X. The code works side-by side with objective-C which allows the code to run fast. It is concise and is fun to code.

Whats the Difference between swift and Objective-C ?

Except for the syntax and a lot of new paradigms. Swift is very easy to get to grips with and there were a few things that made the code easier to write than Obective-C. Unlike Obective-C, Swift doesn’t need the use of brackets when defining parameters or semi colons to end the line of code. In addition the code isn’t pedantic and doesn’t return errors when spaces are missed out or the sentences are structured in a different order. This allows the programmer to focus on the app rather than the code.On the performance level, Swift is more impressive than Objective C. This is because Objective C does not allow a compiler to do a lot of optimisation due to its dynamic nature. With Swift, there is much more room for optimisation at compile time. Apple states that Swift is 2.6 times faster than Objective C code. Overall, it results in much better performance. There is still a lot of debate on the web, but it’s mostly about tools and less about language – buggy issues and surprises due to the young age of Swift.

How is Objective C better than Swift?

First of all, Swift has all of the capabilities of communicating with Objective C code, as you can incorporate parts of objective-C within a swift project. However, libraries are not the most pleasant to work with. There are some challenges to constructing the Swift code, e.g. many nested blocks to unwrap the optional values. Overall, it ends up becoming a huge tree – some call it a pyramid of doom. There are ways to overcome this, but it is still not perfect. Talking about advantages of Objective C would likely lead to discussing Swift pain points, because there is not much Objective C has that is better than Swift.

We use swift because it is the future of coding. It has only been around for a year however it has already made massive advancements on Objective-C and once the buggy issues get sorted it will be far superior.

Programming: Sidebar Menu Prototype

For the app, we wanted to create a sidebar menu so the user will be able to select certain clauses within the app and hide other clauses. These categories included; the main clauses, church related, money orientated, justice, peace, women and royalty. As we are using a very high quality image of the Magna Carta for the basis of the Magna Carta, we were very keen on creating a function that will allow the user to hide the overlays, that display the translation and contextualisation for each clause.The reason behind this is that there are tiny details within the app that aren’t visible until you zoom into the document; for example a piece of wood stuck into the parchment. We feel that these details are valuable to the heritage of  the document and an interesting factor that people may not consider. Also as all the clauses will be highlighted using overlays it could be very distracting and may take away the impact and power of the document, therefore this function will limit this.

Some of the examples of different side bars that we have looked include;

2
Spotify Side Bar Menu
3
Peterest Side Menu
4
BBC Weather Side Bar

        

 

 

 

 

 

 

From these examples we found that the applications use libraries that have been already coded and import them into the app, very similarly to the map kit Apple supply to create apps with maps. We looked at an open source library called SWRevealViewController to build the sidebar menu. Though the library was written in Objective-C,  however it is possible to integrate it into any Swift project. This is done by accessing and interacting with Objective-C classes using Swift.

As we hadn’t created side bar menu’s before we decided to create a separate project working out how the side bar would programmatically work then after we had a prototype for the side bar, we would amalgamate the two together.

Below is a screenshot of the Storyboard for the prototype. It uses the side bar menu as a new screen which which is then navigated through the navigation controller to the views of the various screens. The custom SWRevealViewControllerSeguePushController (which is the side bar menu view) segue automatically handles the switching of the controllers. This can be seen from the lines connecting the view controller to the navigation controller to the clause views.

Storyboard
Storyboard

Below we can see, the SWRevealViewController provides a method called revealViewController() to get the parent SWRevealViewController from any child controller. It also provides the revealToggle: method to handle the expansion and contraction of the sidebar menu. We set the target of the menu button to the reveal view controller and action to the revealToggle: method. So when the menu button is tapped, it will call the revealToggle: method to display the sidebar menu.

Implementation of side bar
Implementation of side bar

The premise behind this side bar menu is that it uses segues to navigate from one screen to another which works well for the majority of Apps however our Magna Carta app will be using UIview’s within the same screen therefore the Side menu Bar that we have created here won’t be able to simply pull together with our original prototype. Therefore hopefully with the help of Marc or Kyle we will be able to use the menu that we have created, adapt it a little and be able to have a menu that works within our Magna Carta app.

First Prototype

Producing a prototype for the client to see is an essential part of client to agency development. We have been working in recent weeks in developing our ideas with the clients to create a section of the application to fit their needs and requirements.

Prototype-MockPrototype-Mock-2Prototype-Mock-3

From our creative ideas, the discussions with the client and the requirements  of a heritage applications we have established understanding of an application which would fulfill a specific need for the client/Cathedral. The idea was disscussed in the pervious post feedback.

From our MoSCoW (the application requirements) we have produced a prototype of the hot spots on the image working.

The idea for this prototype was to get a basic understand of how the app with function and look, both for our sake and for that of the client. For this prototype we used an image found online as a starting point as currently we don’t have the official high-resolution image we’d need to use in the final app.

The image was put into Photoshop so we could find the exact pixel coordinates so that we can draw the hot spot boxes over the clauses in Swift. At this point we don’t actually know where each clause starts and ends, so we made random selections as examples to show how it looks.

For this prototype we only had one hot spot as it would be a waste of our time at this point to bother making more as we don’t have the correct image, and we don’t know the actual locations of the clauses.

blog1

Below is the code that was commented to help the project move along, so the teams members that we programming the application would be able to understand what parts of the code do what. The main focus for the first prototype was to work out the gestures and basic functionality of the app.

Screen Shot 2015-04-20 at 11.27.31
Code for User Interface

From the code above, it defines what image is going to be used for the user interface. This code is important and its the basic structure of how the application will be used as the client wants the High res image of the Magna Carta as the core navigational structure.

Screen Shot 2015-04-20 at 11.27.43
Code for Double Tap Recognition

As part of the gestures that will be used in the application this is the double tap gesture. The benefit of using this gesture is that everyone that owns or uses an iPad are familiar with this gesture therefore to conform to the style of apple products it makes sense to have this gesture included within the app.

Code for maximum zoom
Code for maximum zoom

As we are used gestures to be able to zoom into the image, it is important to define how far we want the image to be zoomed into otherwise the user will be able to zoom into the tinniest pixel which isn’t useful therefore we have defined it by 5x zoom.

Screen Shot 2015-04-20 at 11.28.43
Code for alert

The whole concept for the app is to be able to click on parts of the Magna Carta on the clauses therefore it was crucial for our first prototype to have an element of this. This part of the code is the start this. The function that is called is when the overlay is tapped something is meant to happen, in other versions it will pull the information of the clause that is selected but as an initial prototype this code activates an alert.

Screen Shot 2015-04-20 at 11.29.10
Code for Gestures

It was important that within the tap gestures that we defined how much the double tap will scale in (zoom). At the moment we have defined the number at 1.5 so each time you double tap it zooms in by an appropriate amount. As you can see by defining the ‘newZoomScale’ of and setting a maximum it has achieved this.

View the whole commented code here.

Swift Animations

Using animations in our app will help to make it more visually appealing for its users as well as helping to improve the overall user experience. We have briefly explored animations within our workshops but decided to look further into different animations we could creatively incorporate into our app. For simple view animations, UIKit provides the following basic APIs where parameters can be customised to animate views on the screen:

Considering what can be animated:

  • frame: Change the view’s size and position relative to its superview’s coordinate system.
  • bounds: Change the view’s size.
  • center: Change the view’s position.
  • transform: Modify this property to scale, rotate, or translate the view relative to its center point in 2D space4.
  • alpha: Change the transparency of the view.
  • backgroundColor: Change the view’s background color.
  • contentStretch: Change the way the view’s contents are stretched to fill the available space.

these are just some of the features of an application that can be altered with these small animation code snippets

  • UIView.animateWithDuration(_:, animations:)
  • UIView.animateWithDuration(_:, animations:, completion:)
  • UIView.animateWithDuration(_:, delay:, options:, animations:, completion:)

UIView also provides Spring Animations, Keyframe Animations  and View Transitions which may be of use for our application. Here are some examples of some tutorials I have completed:

Looking at some animation tutorials has been useful, allowing us to develop ideas of how we can incorporate some animated elements in order to improve user experiences of our app. In particular, the transitions animation could be incorporated into out app so that when users click on a clause, a new view pops up containing the translation and more information, of which can be animated like the ‘cover vertical’ or ‘flip horizontal’ example. Also, if we decide to categorise the Magna Carta clauses into a table view, the ‘table list spring animation’ could be of use. The end example in the video, is a spring library that we could embed into our xcode project, it allows you to visually demo all the animations and easily animate properties within our project.

References:

Sanders, M., 2014. Animations In Swift [online]. Available from: http://mathewsanders.com/animations-in-swift-part-two/ [Accessed 25 March 2015].

Echessa, J., 2015. Creating Simple View Animations In Swift [online]. Available from: http://www.appcoda.com/view-animation-in-swift/ [Accessed 25 March 2015].

Github, 2015. MengTo/Spring [online]. Available from: https://github.com/MengTo/Spring [Accessed 25 March 2015].