I've just started using AQGridView from Alan Quatermain more specifically, the SpringBoard demo..
The demo shows icons/tiles that consist of a UIImageView. I'd like to know how to use a custom UIView instead so that I can have an icon with text/button underneath.
I'm currently trawling through the code with no real luck in finding how my icons are created.
Any ideas/suggestions would be greatly appreciated..
Cheers.
Check out AQGridViewCell and, specifically, contentView property. This is similar to customizing UITableViewCell.
Have you checked out three20's TTLauncherView?
Although it is for the iPhone you might be able to adopt it for the iPad. It allows for an icon with text underneath. Though you might have to hack it for inserting a custom UIView in place of the image and text.
I found iOSGuy's tutorial helpful when working with TTLauncherView.
And here is an excerpt from iOSGuy's tutorial to show little bit about how it is setup/used.
TTLauncherView* launcherView = [[TTLauncherView alloc]
initWithFrame:self.view.bounds];
launcherView.backgroundColor = [UIColor blackColor];
launcherView.columnCount = 4;
launcherView.pages = [NSArray arrayWithObjects:
[NSArray arrayWithObjects:
[self launcherItemWithTitle:#"Google"
image:#"bundle://safari_logo.png"
URL:#"http://google.com"],
[self launcherItemWithTitle:#"Apple"
image:#"bundle://safari_logo.png"
URL:#"myAppController/myView"]
, nil]
, nil];
Related
iOS uses standard (blue) tint color for all colored texts in MFMailComposeViewController. This is not good for me, as customer wants his company colors in app. How to change their color to orange?
I am asking specifically about colors of button icons (add image and bell image) and texts containing mail addresses. I already have navigation bar colors changed. In documentation, there is written:
The view hierarchy of this class is private and you must not modify it. You can, however, customize the appearance of an instance by using the UIAppearance protocol.
I have tried to use it, but it is not working (I might doing it a wrong way, as I do not know UIAppearance). This is what I have tried:
[[UIButton appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
[[UILabel appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setTextColor:[UIColor orangeColor]];
As Apple says: https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/index.html
The view hierarchy of this class is private and you must not modify
it. You can, however, customize the appearance of an instance by using
the UIAppearance protocol.
Anyway, you can check this post:
Customizing automatic MFMailComposeViewController opened from UITextView
I got this problem too. Just use:
UIView.appearance().tintColor = .orange
This works fine but there is a flaw. The recipients text will change back to system tintColor(blue) when editing.
Im using:
#define colorApp [UIColor colorWithRed:254/256.f green:64/256.f blue:89/256.f alpha:1.0]
Inside the customSearchView init:
[self setBackgroundColor:colorApp];
searchBar = [[UISearchBar alloc] initWithFrame:frame];
searchBar.barTintColor = colorApp;
[self addSubview:searchBar];
Getting the next result:
I need the searchBarTint color to be the same as the navigation. Translucent doesn't seem to make the work.
I came up with the fix soon after I posted the question.
In case anyone ever faces this problem I used
[self.searchDisplayController.searchBar setBackgroundImage:[UIImage imageNamed:#"pinkBar.png"]
forBarPosition:0
barMetrics:UIBarMetricsDefault];
It seems backgroundColor and barTintColor aren't taking colors same way as the navigation for a UISearchDisplayController since iOS 7. But adding an image with that color just resolves that.
I know it's just a quick fix but it helped me and could help others as it is a minor visual issue.
This might be a long winded explanation but I'd rather say too much than not enough. In a nutshell I need to embed a series of stacked textViews in a single scrollView programatically and I can't get it working. I'm basing my efforts off the Text Architecture sample code in the docs.
http://developer.apple.com/library/mac/#documentation/TextFonts/Conceptual/CocoaTextArchitecture/TextSystemArchitecture/ArchitectureOverview.html
I can create a textView programatically well enough but I can't make two inside a scroll view and have them move as one and be editable. There's a nice little diagram explaining how it's possible to create pagination using the same basic concepts but there is no accompanying code and I haven't been successful at doing it myself. I've made a sad little collage of overlapping textViews where only one is editable so far.
Also, if there is a standard way of accomplishing this, a nudge in the right direction would be most appreciated.
Here's my code:
float w = self.windowView.frame.size.width;
float h = self.windowView.frame.size.height*.5;
NSSize halfSize = NSMakeSize(w,h);
textStorage = [[NSTextStorage alloc]
initWithString:#"Here's to the ones who see things different."];
NSLayoutManager *layoutManager;
layoutManager = [[NSLayoutManager alloc] init];
[textStorage addLayoutManager:layoutManager];
NSTextContainer *textContainer;
textContainer = [[NSTextContainer alloc]
initWithContainerSize:halfSize];
[layoutManager addTextContainer:textContainer];
NSTextContainer *textContainer2;
textContainer2 = [[NSTextContainer alloc]
initWithContainerSize:halfSize];
[layoutManager addTextContainer:textContainer2];
self.windowView = [[NSTextView alloc]
initWithFrame:_windowView.frame
textContainer:textContainer];
[self.window setContentView:_windowView];
[self.window makeKeyAndOrderFront:nil];
[self.window makeFirstResponder:_windowView];
NSTextView *textView = [[NSTextView alloc]init];
[textView setTextContainer:textContainer2];
[self.windowView addSubview:textView];
[textView setFrameSize:halfSize];
NSPoint thePoint = NSMakePoint(0, self.windowView.frame.size.height);
[textView setFrameOrigin:thePoint];
[textView setEditable:YES];
[textView setNeedsDisplay:YES];
I should mention. I'm an enthusiast, but by no means a particularly competent programmer. Completely self taught. (Well, actually the book I bought did most of the teaching). I just finished Hillegrass's Cocoa Programming for Mac OSX and I'm working on a bit of a personal learning project to get the ball rolling. I want to make a screenwriting app which formats scene headings, descriptions, dialogs, characters, etc in different ways and
attaches a bunch of information to each section so that standing over a block would show information about that particular segment (scene info).
I've been making mini apps to test everything I would need and so far I've gone through the Text Attribute Guide and The Text Layout Guide in the docs and have figured out a lot. I'm using Core data and bindings for most of everything but I'm stuck at what is arguably the most important part of the app. Getting the main scrollView to display stacked blocks of differently styled text that can be accessed individually by other parts of the app. (my thoughts are on creating an array of NSTextViews and using current index to link an array of info items to particular blocks, though I keep thinking this feels like a bindings sort of job.)
Thanks in advance!
Omar
I have a navigation bar to which I have added right BarButton successfully. Both the NavigationBar and BarButton are created programmatically. Now according to my requirement I got to add two right BarButtons to my navigation Bar. Can anyone tell me how to do this? My app is targeting ios4.
This code will do the trick for you,
NSArray *barButtonItems= [[NSArray alloc] initWithObjects:self.addButton,self.sortbyButton,nil];
self.navigationItem.rightBarButtonItems=barButtonItems;
where addButton and sortbyButton are 2 separate BarButton Items
I know it is too late but I faced it recently. So here is what I did
Create a UIView in code and add the buttons as subviews into this view.
Create a ToolbarButton using [[UIBarButtonItem alloc] initWithCustomView:buttons]
Assign this toolbar button as the Left or right barbuttonItem as U wish.
If you application is targeting iOS 4 and above then you should take UISegmentControl and have two segments on it. Catch value changed action event and check which segment is selected and do you operation accordingly.
You can also set images to segments to make look and feel better.
As the documentation to UINavigationItem1 describes, it has a property rightBarButtonItems (as well as leftBarButtonItems) where you can give an array of UIBarButtons. They are display from right (index 0) to left (index n-1).
#Matthias, As stated in documentation, rightBarButtonItems property is available from iOS 5 and above and this function needs to be supported also on iOS 4.
So, UISegmentControl is best way to achieve this.
NSArray *segmentTextContent = [NSArray arrayWithObjects:
NSLocalizedString(#\"Group By\", #\"\"),
NSLocalizedString(#\"Filter By\", #\"\"),
nil];
UISegmentedcontrol *segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent];
segmentedControl.selectedSegmentIndex = 0;
segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.frame = CGRectMake(0, 0, 125, 30);
[segmentedControl addTarget:self action:#selector(toggleUnit) forControlEvents:UIControlEventValueChanged];
segmentedControl.tintColor = [UIColor lightGrayColor];
defaultTintColor = [segmentedControl.tintColor retain];
self.navigationItem.rightBarButtonItem = segmentedControl;
[segmentedControl release];
I am trying to add an overlay image to a photo that is taken. Has anyone seen any examples on how I can do this? I want to have a picture which is a transparent PNG file, and then allow the user to take a picture with the image in it.
Iulius is correct that this is essentially a duplicate question. However, just to rule out one issue-- would you like the user to be able to see the overlay while composing the shot? (i.e. if your app makes different hats appear on people's heads, do you want to show the hat floating in space while they take the photo?). If you want to learn more about that, you'll need to use the cameraOverlayView property of the imagePickerController, which lets you superimpose your own view(s) on the camera. There are questions on this topic already on SO, like this one: How to add a overlay view to the cameraview and save it
Update re: scaling-- LilMoke, I assume when you say that the image is offset you're getting into trouble with the difference with the camera's aspect ratio (4:3) and the screen of the iPhone (3:4). You can define a constant and use it to set the cameraViewTransform property of your UIImagePickerController. Here's a code snippet, partially borrowed, and simplified from the excellent augmented reality tutorial at raywenderlich.com:
#define CAMERA_TRANSFORM 1.24299
// First create an overlay view for your superimposed image
overlay = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
overlay.backgroundColor=[UIColor clearColor];
overlay.opaque = NO;
UIImagePickerController *imagePicker;
imagePicker = [[[UIImagePickerController alloc] init] autorelease];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.showsCameraControls = YES; // assuming you need these?
imagePicker.toolbarHidden = YES;
imagePicker.navigationBarHidden = YES;
imagePicker.wantsFullScreenLayout = YES;
imagePicker.cameraViewTransform = CGAffineTransformScale(imagePicker.cameraViewTransform,
CAMERA_TRANSFORM, CAMERA_TRANSFORM); // If I understood your problem, this should help
imagePicker.cameraOverlayView = overlay;
If code along these lines doesn't get you on track, then maybe you can post all the relevant code from your troubled project here. Hopefully it's just a matter of setting the cameraViewTransform as I said above.