Letterpress
A minimal, Markdown based blogging system written in Python.
Wangling - Letterpress ling wang's blog.
In the WWDC 2013 videos they show that a developer can use a letterpress effect on text.
Does anyone have any example code of how to do this/how to do this with a UILabel?
Source: (StackOverflow)
I am trying to make a game with a Custom Keyboard without using iOS Keyboard Extension. So I decided to make an in-app keyboard. I need help with making a drag and drop effects like Letterpress Game. Ok about my code:
I made a UIImageView
based swift file for my tiles (Tile.swift) and I call it in GameController
.swift
I made a delegate to manage Tile movement in GameController
if Tile is moving (being dragged) -> touchesmoved
will call dragtile function
if Tile ends moving (dropped) -> touchesEnded
will call tileView
Function
Tile.swift has 3 functions to handle touches
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let point = touches.anyObject()!.locationInView(self.superview)
xOffset = point.x - self.center.x
yOffset = point.y - self.center.y
self.transform = CGAffineTransformScale(self.transform, 1.2, 1.2)
self.superview?.bringSubviewToFront(self)
}
override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
let point = touches.anyObject()!.locationInView(self.superview)
if(self.center.y < ScreenHeight/2){
self.center = CGPointMake(point.x - xOffset, point.y - yOffset)
dragDelegate?.dragTile(self, didDragtoPoint: self.center)
}
}
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
self.touchesMoved(touches, withEvent: event)
let point = touches.anyObject()!.locationInView(self.superview)
if CGRectContainsPoint(self.frame, point){
dragDelegate?.tileView(self, didDragToPoint: self.center)
}
}
GameController.swift
private var tiles: [TileView] = []
private var targets:[TileView] = []
func tileView(tileView: TileView, didDragToPoint point: CGPoint) {
???????
}
func dragTile(tileView: TileView, didDragtoPoint: CGPoint) {
???????
}
What is your suggested algorithm for these two functions to handle drag and drop like Letterpress Game??
Letterpress Example
Source: (StackOverflow)
I have an app where I use this code to add letterpress effect to NSStrings in a view:
//NSMutableAttributedString
NSString *nameString = [NSString stringWithFormat:@"Nombre: %@", [[jsonArray objectAtIndex:0] objectForKey:@"nombre"]];
NSString *addressString = [NSString stringWithFormat:@"Direccion: %@", [[jsonArray objectAtIndex:0] objectForKey:@"direccion"]];
NSMutableAttributedString *restName = [[NSMutableAttributedString alloc] initWithString:nameString];
NSMutableAttributedString *addressName = [[NSMutableAttributedString alloc] initWithString:addressString];
[restName addAttributes:@{ NSTextEffectAttributeName : NSTextEffectLetterpressStyle, NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline] } range:NSMakeRange(0, restName.length)];
[addressName addAttributes:@{ NSTextEffectAttributeName : NSTextEffectLetterpressStyle, NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline] } range:NSMakeRange(0, addressName.length)];
self.topVC.restaurantName.attributedText = restName;
self.topVC.restaurantAddress.attributedText = addressName;
but I have another app where I want to add it to a single label in a tableview cell. The thing is that its a static tableview, and i dont have a cellForRowAtIndexPath method where I set the text. How do I go about it?
Source: (StackOverflow)
I would like to use a an image as the color of an letter-pressed label but something is not working right and I am not sure what.
I create the color with
UIImage *redImage = [UIImage imageNamed:@"Red"];
UIColor *redColor = [UIColor colorWithPatternImage:scaledRedImage];
When I create the attributes
NSDictionary *attributes = @{NSForegroundColorAttributeName : redColor, NSTextEffectAttributeName : NSTextEffectLetterpressStyle};
the label is letter-pressed but the color is white.
When using NSDictionary *attributes = @{NSForegroundColorAttributeName : redColor};
, the color is set correctly so I know that the color is created correctly.
NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor redColor], NSTextEffectAttributeName : NSTextEffectLetterpressStyle};
works perfectly.
So to sum up:
- Letterpress + custom color = white letterpressed text
- Letterpress + system color = correctly colored and letterpressed text
- Custom color + no letterpress = correctly colored
Why is this happening and how can I fix it?
Source: (StackOverflow)
How can I recreate the letterpress-like effect applied to the backbarbuttonitem in the notes app in ios 7? I tried the following:
NSShadow *textShadow = [[NSShadow alloc] init];
textShadow.shadowOffset = CGSizeMake(0.0, -1.0);
textShadow.shadowColor = [UIColor blackColor];
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:@"Back" attributes:@{NSForegroundColorAttributeName : [UIColor orangeColor], NSShadowAttributeName : textShadow}];
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:attributedTitle style:UIBarButtonItemStylePlain target:nil action:nil];
But it says I can't use NSAttributedString in place of an NSString.
Source: (StackOverflow)
iOS7 introduced a wonderful "letterpress" text effect that applied via AttributedText to UILabel texts. I need to have that effect in cells of simple table.
Unfortunately being rendered in standard way it caused significant scrolling lags in compare to "textLabel.text" assignments.
Seems attributed text render is very CPU expensive, but iOS embedded apps like Notes scroll without lags. Is it possible to improve render performance?
Below is code sample:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = (MyCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil)
{
cell = [[MyCell alloc] init];
}
NSDictionary *attrs = @{NSTextEffectAttributeName : NSTextEffectLetterpressStyle};
NSString *text = [self textWithCell:indexPath];
//next line causes lags
textLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:text attributes:attrs];
//this works fine
//cell.textLabel.text = text;
}
Source: (StackOverflow)